Fix: only free trace_path when it is dynamically allocated
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 14 Jan 2019 22:13:32 +0000 (17:13 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 21 Jan 2019 21:29:44 +0000 (16:29 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/view.c

index 1e6852e79caf4ee975547752f92104d9f69f746c..bf9b1bef8b1bd8bf1ce130bdb2596e66f92625a1 100644 (file)
@@ -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);
This page took 0.034788 seconds and 4 git commands to generate.