summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-12-08 12:54:10 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-12-09 21:34:51 -0800
commit2e692217544b8712d7bb41776cfd7f1bcca1070b (patch)
tree5514586d4337b6fb4aa517ef809346ea3fe9274c
parentf6316d16b2239220dd9f043bcc628a503f89ab5c (diff)
downloadiceauth-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.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/process.c b/process.c
index 09cb7ef..6f7396d 100644
--- a/process.c
+++ b/process.c
@@ -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 */