From 18d9ccbc91e437c795b71284591874635f52d9ec Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 7 Feb 2014 19:28:42 -0300 Subject: [PATCH] hcidump: Fix memory leak Memory pointed by frm.data variable was not freed in both failure and success flows. --- tools/hcidump.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/hcidump.c b/tools/hcidump.c index 50123d202..2bbc207eb 100644 --- a/tools/hcidump.c +++ b/tools/hcidump.c @@ -309,7 +309,7 @@ static void read_dump(int fd) if (err < 0) goto failed; if (!err) - return; + goto done; if (parser.flags & DUMP_PKTLOG) { switch (ph.type) { @@ -407,7 +407,7 @@ static void read_dump(int fd) if (err < 0) goto failed; if (!err) - return; + goto done; frm.ptr = frm.data; frm.len = frm.data_len; @@ -432,8 +432,13 @@ static void read_dump(int fd) parse(&frm); } +done: + free(frm.data); + return; + failed: perror("Read failed"); + free(frm.data); exit(1); } -- 2.47.3