summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2007-07-17 12:48:31 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2007-07-17 12:48:31 -0700
commitb57637a154a40e874a6bcb351aaa8335e86ae3c0 (patch)
tree5de33f32cc554f1c9c1cc8ab313a04132478bca6
parent72a01c6a3bae2cf113ab0ec812df41fec9b99a51 (diff)
Coverity #678: get_keysym_list: Returned without freeing storage "keysymlist"
Free allocated memory in error path when it's not being returned
-rw-r--r--handle.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/handle.c b/handle.c
index 1cb2a43..fe5b6ac 100644
--- a/handle.c
+++ b/handle.c
@@ -972,6 +972,7 @@ get_keysym_list(char *line, int len, int *np, KeySym **kslistp)
n = skip_chars (line, len);
if (n < 0) {
badmsg0 ("keysym name list");
+ free(keysymlist);
return (-1);
}
@@ -990,12 +991,14 @@ get_keysym_list(char *line, int len, int *np, KeySym **kslistp)
/* grow the list bigger if necessary */
if (havesofar >= maxcanhave) {
+ KeySym *origkeysymlist = keysymlist;
maxcanhave *= 2;
keysymlist = (KeySym *) realloc (keysymlist,
maxcanhave * sizeof (KeySym));
if (!keysymlist) {
badmsg ("attempt to grow keysym list to %ld bytes",
(long) (maxcanhave * sizeof (KeySym)));
+ free(origkeysymlist);
return (-1);
}
}