]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
esx: Fix potential memory leak in esxVI_BuildFullTraversalSpecItem
authorMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 2 Mar 2010 22:15:00 +0000 (23:15 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 23 Mar 2010 00:28:08 +0000 (01:28 +0100)
If esxVI_String_DeepCopyValue or esxVI_SelectionSpec_AppendToList fail
then selectionSpec would leak. Add a free call in the failure path to
fix the leak.

src/esx/esx_vi.c

index aa46532740adfd335aa30c3731b015496dc94112..63ddaa4301dbe48bdea65b4db74eb2a8b56a6d17 100644 (file)
@@ -1163,8 +1163,6 @@ esxVI_BuildFullTraversalSpecItem(esxVI_SelectionSpec **fullTraversalSpecList,
         currentSelectSetName = selectSetNames;
 
         while (currentSelectSetName != NULL && *currentSelectSetName != '\0') {
-            selectionSpec = NULL;
-
             if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0 ||
                 esxVI_String_DeepCopyValue(&selectionSpec->name,
                                            currentSelectSetName) < 0 ||
@@ -1173,6 +1171,7 @@ esxVI_BuildFullTraversalSpecItem(esxVI_SelectionSpec **fullTraversalSpecList,
                 goto failure;
             }
 
+            selectionSpec = NULL;
             currentSelectSetName += strlen(currentSelectSetName) + 1;
         }
     }
@@ -1186,6 +1185,7 @@ esxVI_BuildFullTraversalSpecItem(esxVI_SelectionSpec **fullTraversalSpecList,
 
   failure:
     esxVI_TraversalSpec_Free(&traversalSpec);
+    esxVI_SelectionSpec_Free(&selectionSpec);
 
     return -1;
 }