From aafac6e102f9a2a44318743e521a3270a580051d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 14 Apr 2022 20:22:03 -0400 Subject: [PATCH] Fix: lttng: enable-channel: leak of popt arguments MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ==1245463==ERROR: LeakSanitizer: detected memory leaks Direct leak of 5 byte(s) in 1 object(s) allocated from: #0 0x7fe7c494fdd9 in __interceptor_malloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145 #1 0x7fe7c44a5c09 (/usr/lib/libpopt.so.0+0x3c09) Arguments obtained with poptGetOptArg() must be free'd. Signed-off-by: Jérémie Galarneau Change-Id: I5a65ca6fbaa18f7717ea918a5bc7f42daeb1009a --- src/bin/lttng/commands/enable_channels.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bin/lttng/commands/enable_channels.cpp b/src/bin/lttng/commands/enable_channels.cpp index 25327473f..a7fffbff1 100644 --- a/src/bin/lttng/commands/enable_channels.cpp +++ b/src/bin/lttng/commands/enable_channels.cpp @@ -644,6 +644,11 @@ int cmd_enable_channels(int argc, const char **argv) ret = CMD_UNDEFINED; goto end; } + + if (opt_arg) { + free(opt_arg); + opt_arg = nullptr; + } } ret = print_missing_or_multiple_domains( @@ -755,5 +760,6 @@ end: /* Overwrite ret if an error occurred when enable_channel */ ret = command_ret ? command_ret : ret; poptFreeContext(pc); + free(opt_arg); return ret; } -- 2.34.1