The machine name g_strdup()ed by add_machine_test_case() is freed by
test_machine().  Since the former runs for all machines, whereas the
latter runs only for the selected test case's machines, this leaks the
names of machines not selected, if any.  Harmless, but fix it anyway:
there is no need to dup in the first place, so don't.

Signed-off-by: Markus Armbruster <arm...@redhat.com>
---
 tests/qtest/qom-test.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c
index 4ade1c728c..cb5dbfe329 100644
--- a/tests/qtest/qom-test.c
+++ b/tests/qtest/qom-test.c
@@ -220,7 +220,6 @@ static void test_machine(gconstpointer data)
     qobject_unref(response);
 
     qtest_quit(qts);
-    g_free((void *)machine);
 }
 
 static void add_machine_test_case(const char *mname)
@@ -228,7 +227,7 @@ static void add_machine_test_case(const char *mname)
     char *path;
 
     path = g_strdup_printf("qom/%s", mname);
-    qtest_add_data_func(path, g_strdup(mname), test_machine);
+    qtest_add_data_func(path, mname, test_machine);
     g_free(path);
 }
 
-- 
2.49.0


Reply via email to