]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemuxml2argvtest: Resolve resource leaks found by Valgrind
authorJohn Ferlan <jferlan@redhat.com>
Mon, 4 Feb 2013 14:54:33 +0000 (09:54 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 7 Feb 2013 19:08:14 +0000 (14:08 -0500)
Valgrind deterimined that fakeSecretGetValue() was using the secret
value without checking validity.  Returning NULL causes the caller
to emit a message and results in failure.

Additionally commit 'b090aa7d' changes leaked vncSASLdir and vncTLSx509certdir

tests/qemuxml2argvtest.c

index 4e90b263bd341ce6404def48cffb83aa88439f43..938dc326da8a84c8a8448e4c69c156156fc6abe7 100644 (file)
@@ -31,6 +31,9 @@ fakeSecretGetValue(virSecretPtr obj ATTRIBUTE_UNUSED,
                    unsigned int internalFlags ATTRIBUTE_UNUSED)
 {
     char *secret = strdup("AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A");
+    if (!secret) {
+        return NULL;
+    }
     *value_size = strlen(secret);
     return (unsigned char *) secret;
 }
@@ -559,7 +562,8 @@ mymain(void)
     driver.config->vncTLSx509verify = 1;
     DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC);
     driver.config->vncSASL = driver.config->vncTLSx509verify = driver.config->vncTLS = 0;
-    driver.config->vncSASLdir = driver.config->vncTLSx509certdir = NULL;
+    VIR_FREE(driver.config->vncSASLdir);
+    VIR_FREE(driver.config->vncTLSx509certdir);
 
     DO_TEST("graphics-sdl", NONE);
     DO_TEST("graphics-sdl-fullscreen", NONE);