Fix memory corruption crash when there are entries with large leading whitespace in options.txt etc (Thanks TrueDJSlimeball)

This commit is contained in:
UnknownShadow200 2021-03-17 11:19:31 +11:00
parent 6cc0b5d80f
commit 3027439a8b

View File

@ -241,9 +241,10 @@ cc_result EntryList_Load(struct StringsBuffer* list, const char* file, char sepa
/* ReadLine reads single byte at a time */
Stream_ReadonlyBuffered(&buffered, &stream, buffer, sizeof(buffer));
String_InitArray(entry, entryBuffer);
for (;;) {
/* Must be re-initialised each time as String_UNSAFE_TrimStart adjusts entry.buffer */
String_InitArray(entry, entryBuffer);
res = Stream_ReadLine(&buffered, &entry);
if (res == ERR_END_OF_STREAM) break;
if (res) { Logger_SysWarn2(res, "reading from", &path); break; }