Commit 9aef0e71 authored by Ben Boeckel's avatar Ben Boeckel

vtkParseMain: handle realloc errors properly

Change-Id: I94a75a4b4e3eb6d8890160dae9bbcbbdb27be27c
parent f4e756f9
......@@ -123,7 +123,14 @@ static int read_option_file(
while (n == maxlen-1 && line[n-1] != '\n' && !feof(fp))
{
maxlen *= 2;
char *oldline = line;
line = (char *)realloc(line, maxlen);
if (!line)
{
free(oldline);
fclose(fp);
return 0;
}
if (!fgets(&line[n], (int)(maxlen-n), fp)) { break; }
n += strlen(&line[n]);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment