[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1429416255-12070-6-git-send-email-namhyung@kernel.org>
Date: Sun, 19 Apr 2015 13:04:13 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Jiri Olsa <jolsa@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>
Subject: [PATCH 5/7] perf hists browser: Fix possible memory leak
The options array saves strings for each popup menu item. The number of
items can be vary according to the currently selected item. So it can
leak some memory if it's exited from a small item. Fix it by freeing
all items when loop terminates.
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
tools/perf/ui/browsers/hists.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 8f303eb5044d..cace2df7e561 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1691,7 +1691,8 @@ skip_annotation:
"Switch to another data file in PWD") > 0)
switch_data = nr_options++;
add_exit_option:
- options[nr_options++] = (char *)"Exit";
+ if (asprintf(&options[nr_options], "Exit") > 0)
+ nr_options++;
retry_popup_menu:
choice = ui__popup_menu(nr_options, options);
@@ -1812,7 +1813,7 @@ out_free_stack:
pstack__delete(fstack);
out:
hist_browser__delete(browser);
- free_popup_options(options, nr_options - 1);
+ free_popup_options(options, ARRAY_SIZE(options));
return key;
}
--
2.3.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists