From: Hannes Reinecke Date: Tue, 17 May 2011 12:46:56 +0000 (+0200) Subject: multipathd: fix memory issues in cli.c X-Git-Tag: upstream/0.5.0~106^2~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c6038a94c06bbd329db4bb6e20d33c64f483f93;p=platform%2Fupstream%2Fmultipath-tools.git multipathd: fix memory issues in cli.c Some memory issues in cli.c have been found by valgrind. Signed-off-by: Hannes Reinecke --- diff --git a/multipathd/cli.c b/multipathd/cli.c index 7851a3e..3316004 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -232,10 +232,9 @@ get_cmdvec (char * cmd, vector *v) strvec = alloc_strvec(cmd); if (!strvec) - return 0; + return E_NOMEM; cmdvec = vector_alloc(); - *v = cmdvec; if (!cmdvec) { free_strvec(strvec); @@ -275,17 +274,17 @@ get_cmdvec (char * cmd, vector *v) r = E_NOPARM; goto out; } + *v = cmdvec; free_strvec(strvec); return 0; out: free_strvec(strvec); free_keys(cmdvec); - *v = NULL; return r; } -static int +static int fingerprint(vector vec) { int i; @@ -372,8 +371,6 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data) r = get_cmdvec(cmd, &cmdvec); if (r) { - if (cmdvec) - free_keys(cmdvec); *reply = genhelp_handler(); *len = strlen(*reply) + 1; return 0; @@ -381,7 +378,7 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data) h = find_handler(fingerprint(cmdvec)); - if (!h) { + if (!h || !h->fn) { *reply = genhelp_handler(); *len = strlen(*reply) + 1; free_keys(cmdvec);