mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-05-14 13:18:09 +02:00
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: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit e6733ae91b)
This commit is contained in:
parent
157cc02fc1
commit
2ac840a149
1 changed files with 6 additions and 3 deletions
|
|
@ -1789,11 +1789,14 @@ GetFontPath(ClientPtr client, int *count, int *length, unsigned char **result)
|
|||
fpe = font_path_elements[i];
|
||||
len += fpe->name_length + 1;
|
||||
}
|
||||
font_path_string = (unsigned char *) realloc(font_path_string, len);
|
||||
if (!font_path_string)
|
||||
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];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue