From a074b48f33ff0c657d360575e7fa9f3dc9f3e569 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Thu, 18 Apr 2019 11:18:31 +0200 Subject: [PATCH] Fix a memory leak in real_path Running the testsuite with AddressSanitizer turned on flagged a memory leak in real_path, in abg-tools-utils.cc. Fixed thus. * src/abg-tools-utils.cc (real_path): Fee the returned pointer of realpath. Signed-off-by: Dodji Seketeli --- src/abg-tools-utils.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index 58fe985e..9040a44a 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -405,7 +405,10 @@ real_path(const string&path, string& result) char *realp = realpath(path.c_str(), NULL); if (realp) - result = realp; + { + result = realp; + free(realp); + } } /// Ensures #dir_path is a directory and is created. If #dir_path is -- 2.43.5