Bug 327535 - Crash in CSV Importer.
Summary: Crash in CSV Importer.
Alias: None
Product: kmymoney
Classification: Unclassified
Component: general (show other bugs)
Version: git (master)
Platform: Mint (Ubuntu based) Linux
: NOR crash (vote)
Target Milestone: ---
Assignee: allan
Depends on:
Reported: 2013-11-12 23:44 UTC by allan
Modified: 2013-12-28 13:59 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:

Patch file for this bug. Needed fix also if debitCreditRadioClicked() in similar circumstances. (2.31 KB, patch)
2013-11-15 11:59 UTC, allan

Note You need to log in before you can comment on or make changes to this bug.
Description allan 2013-11-12 23:44:36 UTC
This does not affect the stable releases.
If a file with say three columns, that  is with just a single 'Amount column', is loaded after a file with Debit and Credit columns was previously loaded, then during the process of column selection, when the Amount radio button is clicked, KMyMoney crashes.

Reproducible: Always

Steps to Reproduce:
1. Import a file which has debit and credit columns.
2. Exit the plugin so that the settings are saved.
3. Load a file which has just the single Amount column.
4. The Amount column radio should be showing as deselected and the Debit/credit columns radio should be showing as selected.
5. Click the Amount radio button.
6. KMM crashes.
Actual Results:  
as above.

Expected Results:  
KMM should not crash.

When the Amount column radio is clicked, the routine CSVDialog::amountRadioClicked() is entered.  The m_debitColumn and m_creditColumn integers are set to -1, that is set to invalid.  However, before this action, a check is made - "the 'm_creditColumn and m_debitColumn' could just have been reassigned, so ensure they == "credit or debit" before clearing them".
so, before the current settings are cleared, they are actually used for this check.
Unfortunately, it is likely that one or both of them points to a now non-existent column, causing the m_columnTypeList QStringList[] to go out of bounds, resulting in the crash.
The use of  a QStringList[] for this check needs to be changed to an indexOf() operation.
Comment 1 allan 2013-11-15 11:59:20 UTC
Created attachment 83582 [details]
Patch file for this bug. Needed fix also if debitCreditRadioClicked() in similar circumstances.

Waiting on prior reviewboard before pushing this.
Comment 2 allan 2013-12-28 13:59:10 UTC
Git commit 243a5994583e91bf1c2e166abecfec74bf87d7a9 by Allan Anderson.
Committed on 28/12/2013 at 13:50.
Pushed by allananderson into branch 'master'.

M  +6    -6    kmymoney/plugins/csvimport/csvdialog.cpp