Fix: lttng: leak of userspace probe path on listing
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 23 Jun 2020 03:35:02 +0000 (23:35 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 29 Jul 2020 17:03:42 +0000 (13:03 -0400)
realpath() returns a malloc'ed string when `resolved_path` is NULL.
`binary_path` can be safely free'd after it is printed.

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

src/bin/lttng/commands/list.c

index 8f44b6a77300ce77391930cb5668615699c80fe1..fa7e044601822a710d425af40546d3d17d7f6590 100644 (file)
@@ -279,7 +279,7 @@ static void print_userspace_probe_location(struct lttng_event *event)
        case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
        {
                const char *function_name;
-               const char *binary_path;
+               char *binary_path;
 
                MSG("%sType: Function", indent8);
                function_name = lttng_userspace_probe_location_function_get_function_name(location);
@@ -298,12 +298,14 @@ static void print_userspace_probe_location(struct lttng_event *event)
                        MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
                        break;
                }
+
+               free(binary_path);
                break;
        }
        case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
        {
                const char *probe_name, *provider_name;
-               const char *binary_path;
+               char *binary_path;
 
                MSG("%sType: Tracepoint", indent8);
                probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
@@ -319,6 +321,8 @@ static void print_userspace_probe_location(struct lttng_event *event)
                        MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
                        break;
                }
+
+               free(binary_path);
                break;
        }
        default:
This page took 0.027486 seconds and 4 git commands to generate.