From 54bd3caf7aad612852d06c6b69a9190be25dbbcd Mon Sep 17 00:00:00 2001 From: "Thibault, Daniel" Date: Tue, 31 Jan 2012 14:32:56 -0500 Subject: [PATCH] Fix memory leak in create command Signed-off-by: Daniel U. Thibault Signed-off-by: David Goulet --- src/bin/lttng/commands/create.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index 99e5daa93..3a4b6f30f 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -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); } -- 2.34.1