[lttng-dev] [PATCH] list.c : fix list_ust_events() memory leak

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Mon Feb 13 13:52:02 EST 2012


>From c26873bade41fe1ef8c3b61d54cdcb708916da74 Mon, 13 Feb 2012 13:51:11 -0500
From: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>
Date: Mon, 13 Feb 2012 13:50:58 -0500
Subject: [PATCH] list.c : fix list_ust_events() memory leak

Signed-off-by: Daniel U. Thibault <daniel.thibault at drdc-rddc.gc.ca>

diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c
index 322f695..9432d35 100644
--- a/src/bin/lttng/commands/list.c
+++ b/src/bin/lttng/commands/list.c
@@ -246,6 +246,7 @@
 static int list_ust_events(void)
 {
 	int i, size;
+	char *cmdline;
 	struct lttng_domain domain;
 	struct lttng_handle *handle;
 	struct lttng_event *event_list;
@@ -278,7 +279,9 @@
 	for (i = 0; i < size; i++) {
 		if (cur_pid != event_list[i].pid) {
 			cur_pid = event_list[i].pid;
-			MSG("\nPID: %d - Name: %s", cur_pid, get_cmdline_by_pid(cur_pid));
+			cmdline = get_cmdline_by_pid(cur_pid);
+			MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
+			free(cmdline);
 		}
 		print_events(&event_list[i]);
 	}
------------------------------

Daniel U. Thibault
R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier)
Système de systèmes (SdS) / System of Systems (SoS)
Solutions informatiques et expérimentations (SIE) / Computing Solutions and Experimentations (CSE)
2459 Boul. Pie XI Nord
Québec, QC  G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538
NAC: 918V QSDJ
Gouvernement du Canada / Government of Canada
<http://www.valcartier.drdc-rddc.gc.ca/>



More information about the lttng-dev mailing list