From e2ecf532ebfc7c4e47b97f1465767568fc0c5aee Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 15 Apr 2022 01:55:45 -0400 Subject: [PATCH] Tests: fix: lttng-create: leaked command parameter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ==1853705==ERROR: LeakSanitizer: detected memory leaks Direct leak of 3 byte(s) in 1 object(s) allocated from: #0 0x7fb67ee0edd9 in __interceptor_malloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145 #1 0x7fb67e964c09 (/usr/lib/libpopt.so.0+0x3c09) Signed-off-by: Jérémie Galarneau Change-Id: I2f3346157cb26de6712c6e6ebd5fafa6b51fac08 --- src/bin/lttng/commands/create.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bin/lttng/commands/create.cpp b/src/bin/lttng/commands/create.cpp index c5c918ce9..64cf2b37c 100644 --- a/src/bin/lttng/commands/create.cpp +++ b/src/bin/lttng/commands/create.cpp @@ -673,6 +673,11 @@ int cmd_create(int argc, const char **argv) uint64_t v; errno = 0; + if (opt_arg) { + free(opt_arg); + opt_arg = nullptr; + } + opt_arg = poptGetOptArg(pc); if (!opt_arg) { /* Set up default values. */ @@ -803,6 +808,7 @@ end: /* Overwrite ret if an error occurred in create_session() */ ret = command_ret ? command_ret : ret; + free(opt_arg); poptFreeContext(pc); return ret; } -- 2.34.1