Skip to content

Commit b0ffcbb

Browse files
committed
Don't access line if reader returns NULL
1 parent 8548877 commit b0ffcbb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ini.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
107107
#endif
108108
#if INI_ALLOW_REALLOC && !INI_USE_STACK
109109
char* new_line;
110-
char* rstatus;
111110
#endif
112111
char section[MAX_SECTION] = "";
113112
#if INI_ALLOW_MULTILINE
@@ -151,9 +150,10 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
151150
return -2;
152151
}
153152
line = new_line;
154-
rstatus = reader(line + offset, (int)(max_line - offset), stream);
153+
if (reader(line + offset, (int)(max_line - offset), stream) == NULL)
154+
break;
155155
offset += strlen(line + offset);
156-
if (rstatus == NULL || max_line >= INI_MAX_LINE)
156+
if (max_line >= INI_MAX_LINE)
157157
break;
158158
}
159159
#endif

0 commit comments

Comments
 (0)