summaryrefslogtreecommitdiff
path: root/tests/virhostdevtest.c
diff options
context:
space:
mode:
authorJohn Ferlan <jferlan@redhat.com>2019-08-07 09:57:46 -0400
committerJohn Ferlan <jferlan@redhat.com>2019-08-07 11:44:17 -0400
commit59a3b79506cc6921c24b8e0042c95178fec2c368 (patch)
tree8346316f4c7c0be1f09479675a89404708b76215 /tests/virhostdevtest.c
parent4e02d52ab9839ca3dc918362563ea407293dad58 (diff)
downloadlibvirt-59a3b79506cc6921c24b8e0042c95178fec2c368.tar.gz
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> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Diffstat (limited to 'tests/virhostdevtest.c')
-rw-r--r--tests/virhostdevtest.c4
1 files changed, 1 insertions, 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;
}