[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] cutils: Fix memleak in get_relocated_path()
From: |
Zhenzhong Duan |
Subject: |
[PATCH] cutils: Fix memleak in get_relocated_path() |
Date: |
Tue, 27 Apr 2021 06:30:42 +0800 |
Valgrind complains definitely loss in get_relocated_path(), because
GString is leaked in get_relocated_path() when returning with gchar *.
Use g_string_free(, false) to free GString while preserving gchar *.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
util/cutils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/cutils.c b/util/cutils.c
index ee908486da..f58c2157d2 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -1055,5 +1055,5 @@ char *get_relocated_path(const char *dir)
assert(G_IS_DIR_SEPARATOR(dir[-1]));
g_string_append(result, dir - 1);
}
- return result->str;
+ return g_string_free(result, FALSE);
}
--
2.25.1
- [PATCH] cutils: Fix memleak in get_relocated_path(),
Zhenzhong Duan <=