Gitlab updates will be applied at 1:30pm, (17:30 UTC), today. No downtime expected.

Commit 79abddf1 authored by Ben Boeckel's avatar Ben Boeckel

vtkWrapHierarchy: handle realloc errors properly

Change-Id: I4aaa036dd2a5d1372789e996cf48bdd07ea88e56
parent 86e47ae8
......@@ -634,7 +634,13 @@ static char **vtkWrapHierarchy_ReadHierarchyFile(FILE *fp, char **lines)
while (n == maxlen-1 && line[n-1] != '\n' && !feof(fp))
{
maxlen *= 2;
char *oldline = line;
line = (char *)realloc(line, maxlen);
if (!line)
{
free(oldline);
return NULL;
}
if (!fgets(&line[n], (int)(maxlen-n), fp)) { break; }
n += strlen(&line[n]);
}
......@@ -707,7 +713,13 @@ static int vtkWrapHierarchy_CompareHierarchyFile(FILE *fp, char *lines[])
while (n == maxlen-1 && line[n-1] != '\n' && !feof(fp))
{
maxlen *= 2;
char *oldline = line;
line = (char *)realloc(line, maxlen);
if (!line)
{
free(oldline);
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