Fix memory leak in create command
authorThibault, Daniel <Daniel.Thibault@drdc-rddc.gc.ca>
Tue, 31 Jan 2012 19:32:56 +0000 (14:32 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 1 Feb 2012 17:53:55 +0000 (12:53 -0500)
Signed-off-by: Daniel U. Thibault <daniel.thibault@drdc-rddc.gc.ca>
Signed-off-by: David Goulet <dgoulet@efficios.com>
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.033468 seconds and 4 git commands to generate.