qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH trivial] init_paths: fix minor memory leak


From: Kirill Batuzov
Subject: [Qemu-devel] [PATCH trivial] init_paths: fix minor memory leak
Date: Thu, 10 Apr 2014 18:07:57 +0400

Fields "name" (created with strdup in new_entry) and "pathname"
(created with g_strdup_printf in new_entry) of pathelem struct should
be freed before the whole struct is.

Signed-off-by: Kirill Batuzov <address@hidden>
---
 util/path.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/util/path.c b/util/path.c
index 623219e..5c59d9f 100644
--- a/util/path.c
+++ b/util/path.c
@@ -160,7 +160,9 @@ void init_paths(const char *prefix)
     base = new_entry("", NULL, pref_buf);
     base = add_dir_maybe(base);
     if (base->num_entries == 0) {
-        free (base);
+        g_free(base->pathname);
+        free(base->name);
+        free(base);
         base = NULL;
     } else {
         set_parents(base, base);
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]