[libvirt PATCH] util/virgdbus: fix memory leak in virGDBusIsServiceInList

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

 



g_variant_iter_loop() handles freeing all arguments unless we break out
of the loop, in that case we have to free them manually.

Reported-by: Peter Krempa <pkrempa@xxxxxxxxxx>
Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/virgdbus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/util/virgdbus.c b/src/util/virgdbus.c
index cd9ca8d5d6..4360a6acff 100644
--- a/src/util/virgdbus.c
+++ b/src/util/virgdbus.c
@@ -359,8 +359,10 @@ virGDBusIsServiceInList(const char *listMethod,
 
     g_variant_get(reply, "(as)", &iter);
     while (g_variant_iter_loop(iter, "s", &str)) {
-        if (STREQ(str, name))
+        if (STREQ(str, name)) {
+            g_free(str);
             return 0;
+        }
     }
 
     return -2;
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux