Fix memory leak in create command
[lttng-tools.git] / src / bin / lttng / commands / create.c
index 99e5daa932511bd0b891a773df2be7dc5399a55d..3a4b6f30ff826b3b72b971719b0f4a42d3cc0b1d 100644 (file)
@@ -101,9 +101,8 @@ static int create_session()
                        goto error;
                }
 
-               ret = asprintf(&traces_path, "%s/" DEFAULT_TRACE_DIR_NAME
-                                       "/%s-%s", alloc_path, session_name, datetime);
-
+               ret = asprintf(&traces_path, "%s/" DEFAULT_TRACE_DIR_NAME "/%s-%s",
+                               alloc_path, session_name, datetime);
                if (ret < 0) {
                        perror("asprintf trace dir name");
                        ret = CMD_ERROR;
@@ -132,6 +131,10 @@ static int create_session()
        ret = CMD_SUCCESS;
 
 error:
+       if (opt_session_name == NULL) {
+               free(session_name);
+       }
+
        if (alloc_path) {
                free(alloc_path);
        }
This page took 0.025605 seconds and 5 git commands to generate.