summaryrefslogtreecommitdiff
path: root/lib/librte_cmdline
diff options
context:
space:
mode:
authorErik Ziegenbalg <eziegenb@brocade.com>2015-05-19 17:04:55 -0700
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-05-29 20:27:23 +0200
commit5f3aa4a702d2cf4c05f52f3eb5fba7437e76bde7 (patch)
treef138509b53b4ee1c4ee75c632fe534e0cd08ca6e /lib/librte_cmdline
parent8c9a33744bf790f106084fc4fdbc7ff27bebe677 (diff)
downloaddpdk-5f3aa4a702d2cf4c05f52f3eb5fba7437e76bde7.zip
dpdk-5f3aa4a702d2cf4c05f52f3eb5fba7437e76bde7.tar.gz
dpdk-5f3aa4a702d2cf4c05f52f3eb5fba7437e76bde7.tar.xz
cmdline: fix small memory leak
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>
Diffstat (limited to 'lib/librte_cmdline')
-rw-r--r--lib/librte_cmdline/cmdline.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c
index 6a55f1f..c405878 100644
--- a/lib/librte_cmdline/cmdline.c
+++ b/lib/librte_cmdline/cmdline.c
@@ -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);