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

[libvirt] [PATCH 2/6] test_conf: Resolve Coverity RESOURCE_LEAK



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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/test_conf.c b/tests/test_conf.c
index 05704df..4d05d8d 100644
--- a/tests/test_conf.c
+++ b/tests/test_conf.c
@@ -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;
 }
-- 
1.7.12.4



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