common: cli: avoid memory leak
authorPeng Fan <peng.fan@nxp.com>
Tue, 22 Dec 2015 09:14:13 +0000 (17:14 +0800)
committerTom Rini <trini@konsulko.com>
Mon, 4 Jan 2016 17:25:35 +0000 (12:25 -0500)
Whether CONFIG_SYS_HUSH_PARSER is defined or not, should always
check to free 'buff' to avoid memory leak.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Simon Glass <sjg@chromium.org>
common/cli.c

index fbcd339c9beeb2998c68876f942811426c060682..119d282bc240d82ba4cfcc050c1cb5c118709cb1 100644 (file)
@@ -103,9 +103,9 @@ int run_command_list(const char *cmd, int len, int flag)
         * is pretty rare.
         */
        rcode = cli_simple_run_command_list(buff, flag);
+#endif
        if (need_buff)
                free(buff);
-#endif
 
        return rcode;
 }