diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-12-08 12:54:10 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-12-09 21:34:51 -0800 |
commit | 2e692217544b8712d7bb41776cfd7f1bcca1070b (patch) | |
tree | 5514586d4337b6fb4aa517ef809346ea3fe9274c | |
parent | f6316d16b2239220dd9f043bcc628a503f89ab5c (diff) | |
download | iceauth-2e692217544b8712d7bb41776cfd7f1bcca1070b.tar.gz |
Free old argv array if realloc fails to enlarge it
Found by cppcheck:
[app/iceauth/process.c:302]: (error) Common realloc mistake:
'argv' nulled but not freed upon failure
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | process.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -298,9 +298,13 @@ static char **split_into_words ( /* argvify string */ savec = *src; *src = '\0'; if (cur == total) { + char **prevargv = argv; total += WORDSTOALLOC; argv = (char **) realloc (argv, total * sizeof (char *)); - if (!argv) return NULL; + if (!argv) { + free (prevargv); + return NULL; + } } argv[cur++] = jword; if (savec) src++; /* if not last on line advance */ |