From 4df1f2d4355df325341578644db615b840eaa116 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 22 Jun 2020 23:35:02 -0400 Subject: [PATCH] Fix: lttng: leak of userspace probe path on listing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Change-Id: Ic35862f3275f58274ae2572e1d6be736f8a2107e --- src/bin/lttng/commands/list.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 372a71dad..e96fe35dc 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -273,7 +273,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); @@ -292,12 +292,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); @@ -313,6 +315,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: -- 2.34.1