cmdline: fix small memory leak
authorErik Ziegenbalg <eziegenb@brocade.com>
Wed, 20 May 2015 00:04:55 +0000 (17:04 -0700)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 29 May 2015 18:27:23 +0000 (20:27 +0200)
A function in cmdline.c has a return that does not free buf properly.

Signed-off-by: Erik Ziegenbalg <eziegenb@brocade.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: John McNamara <john.mcnamara@intel.com>
lib/librte_cmdline/cmdline.c

index 6a55f1f..c405878 100644 (file)
@@ -193,8 +193,10 @@ cmdline_printf(const struct cmdline *cl, const char *fmt, ...)
        va_start(ap, fmt);
        ret = vsnprintf(buf, BUFSIZ, fmt, ap);
        va_end(ap);
-       if (ret < 0)
+       if (ret < 0) {
+               free(buf);
                return;
+       }
        if (ret >= BUFSIZ)
                ret = BUFSIZ - 1;
        write(cl->s_out, buf, ret);