mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
esx: Fix potential memory leak in esxVI_BuildFullTraversalSpecItem
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.
This commit is contained in:
parent
055d21d254
commit
bba36f7fc7
@ -1163,8 +1163,6 @@ esxVI_BuildFullTraversalSpecItem(esxVI_SelectionSpec **fullTraversalSpecList,
|
|||||||
currentSelectSetName = selectSetNames;
|
currentSelectSetName = selectSetNames;
|
||||||
|
|
||||||
while (currentSelectSetName != NULL && *currentSelectSetName != '\0') {
|
while (currentSelectSetName != NULL && *currentSelectSetName != '\0') {
|
||||||
selectionSpec = NULL;
|
|
||||||
|
|
||||||
if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0 ||
|
if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0 ||
|
||||||
esxVI_String_DeepCopyValue(&selectionSpec->name,
|
esxVI_String_DeepCopyValue(&selectionSpec->name,
|
||||||
currentSelectSetName) < 0 ||
|
currentSelectSetName) < 0 ||
|
||||||
@ -1173,6 +1171,7 @@ esxVI_BuildFullTraversalSpecItem(esxVI_SelectionSpec **fullTraversalSpecList,
|
|||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectionSpec = NULL;
|
||||||
currentSelectSetName += strlen(currentSelectSetName) + 1;
|
currentSelectSetName += strlen(currentSelectSetName) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1186,6 +1185,7 @@ esxVI_BuildFullTraversalSpecItem(esxVI_SelectionSpec **fullTraversalSpecList,
|
|||||||
|
|
||||||
failure:
|
failure:
|
||||||
esxVI_TraversalSpec_Free(&traversalSpec);
|
esxVI_TraversalSpec_Free(&traversalSpec);
|
||||||
|
esxVI_SelectionSpec_Free(&selectionSpec);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user