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.9.11~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b3b5288c98c18625bb33eba7d0498551198a7410;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 1e6852e79..bf9b1bef8 100644 --- a/src/bin/lttng/commands/view.c +++ b/src/bin/lttng/commands/view.c @@ -296,6 +296,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, @@ -373,6 +374,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; @@ -390,7 +392,7 @@ static int view_trace(void) } free_sessions: - if (session_live_mode) { + if (session_live_mode && free_trace_path) { free(trace_path); } free(sessions);