Fix: lttng: snapshot: add-output: leak of max size parameter
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 15 Apr 2022 06:09:53 +0000 (02:09 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 18 May 2022 14:42:38 +0000 (10:42 -0400)
==1920281==ERROR: LeakSanitizer: detected memory leaks

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

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

src/bin/lttng/commands/snapshot.c

index d357983107ed3312357c74199d272e3a4136694c..8db8f558e111ea97697d6280fbfebd2445fc087e 100644 (file)
@@ -624,10 +624,14 @@ int cmd_snapshot(int argc, const char **argv)
                case OPT_MAX_SIZE:
                {
                        uint64_t val;
-                       const char *opt = poptGetOptArg(pc);
-
-                       if (utils_parse_size_suffix((char *) opt, &val) < 0) {
-                               ERR("Unable to handle max-size value %s", opt);
+                       char *max_size_arg = poptGetOptArg(pc);
+                       const int parse_ret = utils_parse_size_suffix(
+                                       (char *) max_size_arg, &val);
+
+                       free(max_size_arg);
+                       if (parse_ret < 0) {
+                               ERR("Unable to handle max-size value %s",
+                                               max_size_arg);
                                cmd_ret = CMD_ERROR;
                                goto end;
                        }
This page took 0.027812 seconds and 4 git commands to generate.