]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util/virgdbus: fix memory leak in virGDBusIsServiceInList
authorPavel Hrdina <phrdina@redhat.com>
Wed, 23 Sep 2020 13:40:37 +0000 (15:40 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 23 Sep 2020 14:22:19 +0000 (16:22 +0200)
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@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/util/virgdbus.c

index cd9ca8d5d6cdb6cb35fa20f97f1700075940e5a5..4360a6acff965926d4c68b6d4843c523940048cb 100644 (file)
@@ -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;