Skip to content

Commit

Permalink
Tests: fix: lttng-create: leaked command parameter
Browse files Browse the repository at this point in the history
==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 <[email protected]>
Change-Id: I2f3346157cb26de6712c6e6ebd5fafa6b51fac08
  • Loading branch information
jgalar committed May 18, 2022
1 parent 69d5d2a commit b26c630
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bin/lttng/commands/create.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,11 @@ int cmd_create(int argc, const char **argv)
uint64_t v;

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

opt_arg = poptGetOptArg(pc);
if (!opt_arg) {
/* Set up default values. */
Expand Down Expand Up @@ -804,6 +809,7 @@ int cmd_create(int argc, const char **argv)
/* Overwrite ret if an error occurred in create_session() */
ret = command_ret ? command_ret : ret;

free(opt_arg);
poptFreeContext(pc);
return ret;
}

0 comments on commit b26c630

Please sign in to comment.