Closed oncer closed 10 years ago
I've pushed a fix for this issue, could you please re-test this issue and post your success here.
Thanks for the quick reply.
I'm not sure why, but file.getline(line, FINI_BUFFER_SIZE);
actually strips the \r\n away for me. The last line of my INI file is empty, and for that line it returns a string with a single \n, causing the crash. So the bug report wasn't entirely accurate in the first place, sorry about that.
I fixed the issue on my end by checking for NULL here:
skey = fini_strtok(line, _T("="));
svalue = fini_strtok(NULL, _T("\n"));
if (skey && svalue)
{
....
Thought it was worth a wild quick try, this is actually a regression from a previously working version, hence it removes the carriage return correctly.
Yeah I mixed my order of operator precedence there, I should have used more parenthesis for clarity anyway.
I should probably mention that I'm on MSVC2010, so the STL methods might behave a little different here.
It has caused me grief in the past with some of the differences here, however as I never use Windows/DOS line endings, I wouldn't notice. The last time was when I created a text file in notepad, notepad++ was much nicer to edit .ini files with, not to mention converting between them.
The parser crashes on empty lines with CR+LF ending. The reason is this code below: if (!(fini_strlen(line) >= 2 && line[0] == '/' && line[1] == '/')) //Ignore comment An empty line with CR+LF will have strlen == 2 and therefore it tries to parse the line. Later in the code you have skey = fini_strtok(line, _T("=")); svalue = fini_strtok(NULL, _T("\n")); which will result in skey: "" and svalue: NULL When the parser tries to access svalue, for example calling strlen, the program will throw an exception, trying to dereference the NULL pointer.