From: Jérémie Galarneau Date: Mon, 14 Jan 2019 22:13:32 +0000 (-0500) Subject: Fix: only free trace_path when it is dynamically allocated X-Git-Tag: v2.10.6~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7b539a245bd02d6f4cbe34fb00f11e76f2f040b1;p=lttng-tools.git Fix: only free trace_path when it is dynamically allocated Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/commands/view.c b/src/bin/lttng/commands/view.c index faca60de8..0325e505c 100644 --- a/src/bin/lttng/commands/view.c +++ b/src/bin/lttng/commands/view.c @@ -302,6 +302,7 @@ static int view_trace(void) int ret; char *session_name, *trace_path = NULL; struct lttng_session *sessions = NULL; + bool free_trace_path = false; /* * Safety net. If lttng is suid at some point for *any* useless reasons, @@ -379,6 +380,7 @@ static int view_trace(void) ret = CMD_ERROR; goto free_sessions; } + free_trace_path = true; } else { /* Get file system session path. */ trace_path = sessions[i].path; @@ -396,7 +398,7 @@ static int view_trace(void) } free_sessions: - if (session_live_mode) { + if (session_live_mode && free_trace_path) { free(trace_path); } free(sessions);