]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
test: Fix fchosttest resource leak
authorJohn Ferlan <jferlan@redhat.com>
Thu, 19 Jan 2017 11:37:43 +0000 (06:37 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Sun, 19 Feb 2017 11:45:09 +0000 (06:45 -0500)
Commit id '666bee3' made fabric_name optional; however, if fabric name
was present, then a leak would occur.

Signed-off-by: John Ferlan <jferlan@redhat.com>
tests/fchosttest.c

index bb35b8846e452701a0c016199aaa62194787db76..0b4a8f20ede02e1ad6b61578954e9171de075458 100644 (file)
@@ -159,6 +159,7 @@ test6(const void *data ATTRIBUTE_UNUSED)
     const char *expect_wwpn = "2102001b32a9da4e";
     char *wwnn = NULL;
     char *wwpn = NULL;
+    char *fabric_wwn = NULL;
     int ret = -1;
 
     if (!(wwnn = virReadFCHost(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_NO_FAB,
@@ -169,8 +170,9 @@ test6(const void *data ATTRIBUTE_UNUSED)
                                "port_name")))
         goto cleanup;
 
-    if (virReadFCHost(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_NO_FAB,
-                      "fabric_name"))
+    if ((fabric_wwn = virReadFCHost(TEST_FC_HOST_PREFIX,
+                                    TEST_FC_HOST_NUM_NO_FAB,
+                                    "fabric_name")))
         goto cleanup;
 
     if (STRNEQ(expect_wwnn, wwnn) ||
@@ -181,6 +183,7 @@ test6(const void *data ATTRIBUTE_UNUSED)
  cleanup:
     VIR_FREE(wwnn);
     VIR_FREE(wwpn);
+    VIR_FREE(fabric_wwn);
     return ret;
 }