summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-01-28 20:27:50 -0800
committerPeter Hutterer <peter.hutterer@who-t.net>2014-02-19 10:24:32 +1000
commit2ac840a14958fe74170518ee2c3a6b2dd88b20bd (patch)
tree4082ada7112dc74651b106cbb83a2d6c082a4570
parent157cc02fc13c998bba70e1652907972015e15e8e (diff)
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 e6733ae91b7be52930f22a87de15fa05819ef948)
-rw-r--r--dix/dixfonts.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 2e34d370f..9a686e69c 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -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];