From 5f3aa4a702d2cf4c05f52f3eb5fba7437e76bde7 Mon Sep 17 00:00:00 2001 From: Erik Ziegenbalg Date: Tue, 19 May 2015 17:04:55 -0700 Subject: [PATCH] cmdline: fix small memory leak A function in cmdline.c has a return that does not free buf properly. Signed-off-by: Erik Ziegenbalg Acked-by: Stephen Hemminger Acked-by: John McNamara --- lib/librte_cmdline/cmdline.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index 6a55f1f5d4..c405878ee8 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); -- 2.20.1