Fix: lttng: enable-rotation: leak of command parameter
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 15 Apr 2022 05:29:46 +0000 (01:29 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 15 Apr 2022 05:30:36 +0000 (01:30 -0400)
==1759491==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 6 byte(s) in 1 object(s) allocated from:
    #0 0x7fdbdc94add9 in __interceptor_malloc /usr/src/debug/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7fdbdc4a0c09  (/usr/lib/libpopt.so.0+0x3c09)

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I29cc6ec4390e71829107f309f162247b9be2868c

src/bin/lttng/commands/enable_rotation.cpp

index 223d47ccafe583e2736b4ce30db1f043bdb45de1..1b79da148065b6f0ace1d3d9eaebb8676f8239b7 100644 (file)
@@ -179,6 +179,10 @@ int cmd_enable_rotation(int argc, const char **argv)
        }
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
+               if (opt_arg) {
+                       free(opt_arg);
+                       opt_arg = nullptr;
+               }
                switch (opt) {
                case OPT_HELP:
                        SHOW_HELP();
@@ -333,6 +337,7 @@ end:
        if (free_session_name) {
                free(session_name);
        }
+       free(opt_arg);
        return cmd_ret;
 
 error:
This page took 0.027546 seconds and 5 git commands to generate.