MoneyTools / MyMoney.Net

MyMoney is a rich client .NET ClickOnce application for managing your personal finances. It is written entirely in C# and is designed for programmers who want easy access to their data and who want to quickly and easily add their own features. Your data will not be locked up in some proprietary format, it is yours to do with as you like.
https://moneytools.github.io/MyMoney.Net/
66 stars 21 forks source link

fix CSV import runtime index out of bound #113

Closed jpdup closed 3 months ago

jpdup commented 7 months ago

I hit runtime crash will doing CSV import, "index out of bound", This insure to say in bounds

clovett commented 3 months ago

Do you have the original CSV that failed, your edits make no sense and in fact your changes break the parser because pos++ is a postfix operator meaning (see failed unit test):

while (pos < len && ch != this._fieldDelimiter)
{
    sb.Append(ch);
    ch = line[pos++]; // peek next char
}

I'm guessing the bug was on line 456 since this one does not check if pos < len. So I'm going to push a simpler fix for you to try that changes only that line. This bug will only happen on malformed csv that has trailing commas at the end of the line.

clovett commented 3 months ago

See fix posted in version 2.1.0.20.