]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Call virCommandFree() in cleanup section
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 26 Jul 2019 20:56:31 +0000 (16:56 -0400)
committerEric Blake <eblake@redhat.com>
Fri, 26 Jul 2019 21:32:29 +0000 (16:32 -0500)
Fix a potential memory leak by calling virCommandFree() in the cleanup
section.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Message-Id: <20190726205633.2041912-3-stefanb@linux.vnet.ibm.com>

tests/commandtest.c

index 991c0572b072ec26e601145e9103b2c45f3f6bec..dfd15a2079aee00af08f6e524f8bf8cf1db40fa3 100644 (file)
@@ -1219,8 +1219,6 @@ static int test27(const void *unused ATTRIBUTE_UNUSED)
         goto cleanup;
     }
 
-    virCommandFree(cmd);
-
     if (!outactual || !erractual)
         goto cleanup;
 
@@ -1236,6 +1234,7 @@ static int test27(const void *unused ATTRIBUTE_UNUSED)
     ret = 0;
 
  cleanup:
+    virCommandFree(cmd);
     VIR_FORCE_CLOSE(pipe1[0]);
     VIR_FORCE_CLOSE(pipe2[0]);
     VIR_FORCE_CLOSE(pipe1[1]);