]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Fix memory leak in mymain
authorJohn Ferlan <jferlan@redhat.com>
Sun, 3 Nov 2019 12:19:48 +0000 (07:19 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 6 Nov 2019 16:27:12 +0000 (11:27 -0500)
Commit 944a35d7f0 added @fakerootdir; however, there are multiple
paths out of mymain that didn't free the memory - so just use the
g_autofree to resolve the potential leak.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tests/qemuhotplugtest.c

index 4ff2b38c8336c40e8e8f16c68129350a5636869f..ebf4582ac1dd831e93bf7500e1af63a3c2b15239 100644 (file)
@@ -595,7 +595,7 @@ mymain(void)
     int ret = 0;
     struct qemuHotplugTestData data = {0};
     struct testQemuHotplugCpuParams cpudata;
-    char *fakerootdir;
+    g_autofree char *fakerootdir = NULL;
 
     fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
 
@@ -875,7 +875,6 @@ mymain(void)
 
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
         virFileDeleteTree(fakerootdir);
-    VIR_FREE(fakerootdir);
 
     qemuTestDriverFree(&driver);
     virObjectUnref(data.vm);