]> xenbits.xensource.com Git - libvirt.git/commitdiff
test_conf: Resolve Coverity RESOURCE_LEAK
authorWang Rui <moon.wangrui@huawei.com>
Mon, 1 Sep 2014 12:08:04 +0000 (20:08 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 3 Sep 2014 19:00:19 +0000 (15:00 -0400)
If the condition 'ret < 0' is true, the code will jump to
'cleanup' and 'conf' won't be freed.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
tests/test_conf.c

index 05704df053db8495fb67e7c3e1ac75f2721911fe..4d05d8dd109fc3902a305bb58a2facfd7c0a8c50 100644 (file)
@@ -11,7 +11,7 @@
 int main(int argc, char **argv)
 {
     int ret, exit_code = EXIT_FAILURE;
-    virConfPtr conf;
+    virConfPtr conf = NULL;
     int len = 10000;
     char *buffer = NULL;
 
@@ -34,7 +34,6 @@ int main(int argc, char **argv)
         fprintf(stderr, "Failed to serialize %s back\n", argv[1]);
         goto cleanup;
     }
-    virConfFree(conf);
     if (fwrite(buffer, 1, len, stdout) != len) {
         fprintf(stderr, "Write failed: %s\n", strerror(errno));
         goto cleanup;
@@ -44,5 +43,6 @@ int main(int argc, char **argv)
 
  cleanup:
     VIR_FREE(buffer);
+    virConfFree(conf);
     return exit_code;
 }