aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2015-06-23 15:04:16 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2015-12-28 13:08:06 +0100
commitaea71067dccd63e5988a57944991a2775ae4e5a7 (patch)
tree087badad640b4d1fc191a865475fe7a85674d06f /nx-X11/programs/Xserver
parentedce25213ffc81389909c827c9aaac27b736b483 (diff)
downloadnx-libs-aea71067dccd63e5988a57944991a2775ae4e5a7.tar.gz
nx-libs-aea71067dccd63e5988a57944991a2775ae4e5a7.tar.bz2
nx-libs-aea71067dccd63e5988a57944991a2775ae4e5a7.zip
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> Rebased against NX: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r--nx-X11/programs/Xserver/dix/dixfonts.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c b/nx-X11/programs/Xserver/dix/dixfonts.c
index 156bba2d0..fac918963 100644
--- a/nx-X11/programs/Xserver/dix/dixfonts.c
+++ b/nx-X11/programs/Xserver/dix/dixfonts.c
@@ -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];