From: Thibault, Daniel Date: Tue, 31 Jan 2012 19:32:56 +0000 (-0500) Subject: Fix memory leak in create command X-Git-Tag: v2.0-pre19~23 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=54bd3caf7aad612852d06c6b69a9190be25dbbcd;p=lttng-tools.git Fix memory leak in create command Signed-off-by: Daniel U. Thibault Signed-off-by: David Goulet --- 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); }