From: Serge Hallyn Date: Tue, 15 Apr 2014 20:49:36 +0000 (-0500) Subject: cppcheck: fix unchecked realloc in lxc_info.c X-Git-Tag: lxc-1.1.0.alpha1~146 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5135b555bb3b406288cb24da8425daeaf3e38dde;p=thirdparty%2Flxc.git cppcheck: fix unchecked realloc in lxc_info.c Signed-off-by: Serge Hallyn Acked-by: Stéphane Graber --- diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c index 24d6f9bd9..e1e39c06a 100644 --- a/src/lxc/lxc_info.c +++ b/src/lxc/lxc_info.c @@ -50,9 +50,13 @@ static int filter_count = 0; static int my_parser(struct lxc_arguments* args, int c, char* arg) { + char **newk; switch (c) { case 'c': - key = realloc(key, keys+1 * sizeof(key[0])); + newk = realloc(key, keys+1 * sizeof(key[0])); + if (!newk) + return -1; + key = newk; key[keys] = arg; keys++; break;