Commit aea71067 authored by Mike Gabriel's avatar Mike Gabriel

On realloc failure, free font_path_string instead of leaking it

Flagged by cppcheck 1.62: [dix/dixfonts.c:1792]: (error) Common realloc mistake: 'font_path_string' nulled but not freed upon failure Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: 's avatarPeter Hutterer <peter.hutterer@who-t.net> Signed-off-by: 's avatarKeith Packard <keithp@keithp.com> Rebased against NX: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
parent edce2521
......@@ -1929,11 +1929,14 @@ GetFontPath(int *count, int *length)
fpe = font_path_elements[i];
len += fpe->name_length + 1;
}
font_path_string = (unsigned char *) xrealloc(font_path_string, len);
if (!font_path_string)
return NULL;
c = realloc(font_path_string, len);
if (c == NULL) {
free(font_path_string);
font_path_string = NULL;
return BadAlloc;
}
c = font_path_string;
font_path_string = c;
*length = 0;
for (i = 0; i < num_fpes; i++) {
fpe = font_path_elements[i];
......
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