esxVI_AutoStartPowerInfo *powerInfoList = NULL;
esxVI_AutoStartPowerInfo *powerInfo = NULL;
esxVI_AutoStartPowerInfo *newPowerInfo = NULL;
+ bool newPowerInfo_isAppended = false;
if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
if (esxVI_AutoStartPowerInfo_Alloc(&newPowerInfo) < 0 ||
esxVI_Int_Alloc(&newPowerInfo->startOrder) < 0 ||
esxVI_Int_Alloc(&newPowerInfo->startDelay) < 0 ||
- esxVI_Int_Alloc(&newPowerInfo->stopDelay) < 0 ||
- esxVI_AutoStartPowerInfo_AppendToList(&spec->powerInfo,
- newPowerInfo) < 0) {
+ esxVI_Int_Alloc(&newPowerInfo->stopDelay) < 0) {
goto cleanup;
}
newPowerInfo->stopDelay->value = -1; /* use system default */
newPowerInfo->stopAction = (char *)"none";
+ if (esxVI_AutoStartPowerInfo_AppendToList(&spec->powerInfo,
+ newPowerInfo) < 0) {
+ goto cleanup;
+ }
+
+ newPowerInfo_isAppended = true;
+
if (esxVI_ReconfigureAutostart
(priv->primary,
priv->primary->hostSystem->configManager->autoStartManager,
esxVI_AutoStartDefaults_Free(&defaults);
esxVI_AutoStartPowerInfo_Free(&powerInfoList);
+ if (!newPowerInfo_isAppended) {
+ esxVI_AutoStartPowerInfo_Free(&newPowerInfo);
+ }
+
return result;
}
{
int result = -1;
esxVI_ObjectSpec *objectSpec = NULL;
+ bool objectSpec_isAppended = false;
esxVI_PropertySpec *propertySpec = NULL;
+ bool propertySpec_isAppended = false;
esxVI_PropertyFilterSpec *propertyFilterSpec = NULL;
if (objectContentList == NULL || *objectContentList != NULL) {
if (esxVI_PropertyFilterSpec_Alloc(&propertyFilterSpec) < 0 ||
esxVI_PropertySpec_AppendToList(&propertyFilterSpec->propSet,
- propertySpec) < 0 ||
- esxVI_ObjectSpec_AppendToList(&propertyFilterSpec->objectSet,
- objectSpec) < 0 ||
- esxVI_RetrieveProperties(ctx, propertyFilterSpec,
+ propertySpec) < 0) {
+ goto cleanup;
+ }
+
+ propertySpec_isAppended = true;
+
+ if (esxVI_ObjectSpec_AppendToList(&propertyFilterSpec->objectSet,
+ objectSpec) < 0) {
+ goto cleanup;
+ }
+
+ objectSpec_isAppended = true;
+
+ if (esxVI_RetrieveProperties(ctx, propertyFilterSpec,
objectContentList) < 0) {
goto cleanup;
}
* Remove values given by the caller from the data structures to prevent
* them from being freed by the call to esxVI_PropertyFilterSpec_Free().
*/
- objectSpec->obj = NULL;
- objectSpec->selectSet = NULL;
+ if (objectSpec != NULL) {
+ objectSpec->obj = NULL;
+ objectSpec->selectSet = NULL;
+ }
+
if (propertySpec != NULL) {
propertySpec->type = NULL;
propertySpec->pathSet = NULL;
}
+ if (!objectSpec_isAppended) {
+ esxVI_ObjectSpec_Free(&objectSpec);
+ }
+
+ if (!propertySpec_isAppended) {
+ esxVI_PropertySpec_Free(&propertySpec);
+ }
+
esxVI_PropertyFilterSpec_Free(&propertyFilterSpec);
return result;
{
int result = -1;
esxVI_ObjectSpec *objectSpec = NULL;
+ bool objectSpec_isAppended = false;
esxVI_PropertySpec *propertySpec = NULL;
+ bool propertySpec_isAppended = false;
esxVI_PropertyFilterSpec *propertyFilterSpec = NULL;
esxVI_ManagedObjectReference *propertyFilter = NULL;
char *version = NULL;
"info.state") < 0 ||
esxVI_PropertyFilterSpec_Alloc(&propertyFilterSpec) < 0 ||
esxVI_PropertySpec_AppendToList(&propertyFilterSpec->propSet,
- propertySpec) < 0 ||
- esxVI_ObjectSpec_AppendToList(&propertyFilterSpec->objectSet,
- objectSpec) < 0 ||
- esxVI_CreateFilter(ctx, propertyFilterSpec, esxVI_Boolean_True,
+ propertySpec) < 0) {
+ goto cleanup;
+ }
+
+ propertySpec_isAppended = true;
+
+ if (esxVI_ObjectSpec_AppendToList(&propertyFilterSpec->objectSet,
+ objectSpec) < 0) {
+ goto cleanup;
+ }
+
+ objectSpec_isAppended = true;
+
+ if (esxVI_CreateFilter(ctx, propertyFilterSpec, esxVI_Boolean_True,
&propertyFilter) < 0) {
goto cleanup;
}
propertySpec->type = NULL;
}
+ if (!objectSpec_isAppended) {
+ esxVI_ObjectSpec_Free(&objectSpec);
+ }
+
+ if (!propertySpec_isAppended) {
+ esxVI_PropertySpec_Free(&propertySpec);
+ }
+
esxVI_PropertyFilterSpec_Free(&propertyFilterSpec);
esxVI_ManagedObjectReference_Free(&propertyFilter);
VIR_FREE(version);