util/virgdbus: fix memory leak in virGDBusIsServiceInList

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>
This commit is contained in:
Pavel Hrdina 2020-09-23 15:40:37 +02:00
parent d6ac9b22d3
commit 784f204e7e

View 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;