From 18ae5652b1a745ece5696835f1d33ac077959fc5 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Thu, 3 Feb 2022 12:40:06 +0100 Subject: [PATCH] Fix realpath(3) memory leak Change-Id: Ic2e2264a8dab194884decfa5acb9035ea712b149 --- src/bugreport-service/diagnostics/diagnostics.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bugreport-service/diagnostics/diagnostics.c b/src/bugreport-service/diagnostics/diagnostics.c index f038cad..71df306 100644 --- a/src/bugreport-service/diagnostics/diagnostics.c +++ b/src/bugreport-service/diagnostics/diagnostics.c @@ -103,17 +103,21 @@ static bool is_report_file(const char *path, const char *reports_dir) if (access(r_path, F_OK) == -1) { _E("access() for %s error: %m\n", path); - return false; + goto out_err; } char *start = strstr(r_path, reports_dir); if (start == NULL) { _I("%s is not within %s\n", r_path, reports_dir); - return false; + goto out_err; } return true; + +out_err: + free(r_path); + return false; } static enum diagnostics_type check_report_type(const char *path) -- 2.7.4