Skip to content

Commit

Permalink
Fix: lttng: enable-channel: leak of popt arguments
Browse files Browse the repository at this point in the history
==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 <[email protected]>
Change-Id: I5a65ca6fbaa18f7717ea918a5bc7f42daeb1009a
  • Loading branch information
jgalar committed May 18, 2022
1 parent 4f5288d commit ccdec6d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bin/lttng/commands/enable_channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,11 @@ int cmd_enable_channels(int argc, const char **argv)
ret = CMD_UNDEFINED;
goto end;
}

if (opt_arg) {
free(opt_arg);
opt_arg = NULL;
}
}

ret = print_missing_or_multiple_domains(
Expand Down Expand Up @@ -756,5 +761,6 @@ int cmd_enable_channels(int argc, const char **argv)
/* Overwrite ret if an error occurred when enable_channel */
ret = command_ret ? command_ret : ret;
poptFreeContext(pc);
free(opt_arg);
return ret;
}

0 comments on commit ccdec6d

Please sign in to comment.