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

[libvirt] [PATCH 2/2] tests: Fix memory leak in mymain



Commit d2899a648 added a new exit path, but didn't free @fakerootdir.
Let's just use VIR_AUTOFREE instead to make life easier.

Found by Coverity

Signed-off-by: John Ferlan <jferlan redhat com>
---
 tests/virhostdevtest.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c
index 7d15a87797..20984f3442 100644
--- a/tests/virhostdevtest.c
+++ b/tests/virhostdevtest.c
@@ -556,7 +556,7 @@ static int
 mymain(void)
 {
     int ret = 0;
-    char *fakerootdir;
+    VIR_AUTOFREE(char *) fakerootdir = NULL;
 
     if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
         fprintf(stderr, "Out of memory\n");
@@ -594,8 +594,6 @@ mymain(void)
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
         virFileDeleteTree(fakerootdir);
 
-    VIR_FREE(fakerootdir);
-
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-- 
2.20.1


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