- IEC 61850 client: avoid double free when operate and select-with-value on APC fails

pull/291/head
Michael Zillgith 5 years ago
parent d08f5a67ac
commit bc29a0b048

@ -523,14 +523,15 @@ ControlObjectClient_operate(ControlObjectClient self, MmsValue* ctlVal, uint64_t
MmsValue_update(self->ctlVal, ctlVal); MmsValue_update(self->ctlVal, ctlVal);
if (self->analogValue)
MmsValue_setElement(self->analogValue, 0, NULL);
self->opertime = operTime; self->opertime = operTime;
success = true; success = true;
exit_function: exit_function:
if (self->analogValue)
MmsValue_setElement(self->analogValue, 0, NULL);
return success; return success;
} }
@ -624,13 +625,14 @@ ControlObjectClient_operateAsync(ControlObjectClient self, IedClientError* err,
else { else {
MmsValue_update(self->ctlVal, ctlVal); MmsValue_update(self->ctlVal, ctlVal);
if (self->analogValue)
MmsValue_setElement(self->analogValue, 0, NULL);
self->opertime = operTime; self->opertime = operTime;
} }
exit_function: exit_function:
if (self->analogValue)
MmsValue_setElement(self->analogValue, 0, NULL);
return invokeId; return invokeId;
} }
@ -703,6 +705,8 @@ prepareSBOwParameters(ControlObjectClient self, MmsValue* ctlVal)
bool bool
ControlObjectClient_selectWithValue(ControlObjectClient self, MmsValue* ctlVal) ControlObjectClient_selectWithValue(ControlObjectClient self, MmsValue* ctlVal)
{ {
bool retVal = true;
resetLastApplError(self); resetLastApplError(self);
char domainId[65]; char domainId[65];
@ -741,22 +745,30 @@ ControlObjectClient_selectWithValue(ControlObjectClient self, MmsValue* ctlVal)
if (mmsError != MMS_ERROR_NONE) { if (mmsError != MMS_ERROR_NONE) {
if (DEBUG_IED_CLIENT) if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: select-with-value failed!\n"); printf("IED_CLIENT: select-with-value failed!\n");
return false;
retVal = false;
goto exit_function;
} }
else { else {
if (writeResult != DATA_ACCESS_ERROR_SUCCESS) { if (writeResult != DATA_ACCESS_ERROR_SUCCESS) {
if (DEBUG_IED_CLIENT) if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: select-with-value failed!\n"); printf("IED_CLIENT: select-with-value failed!\n");
return false;
retVal = false;
goto exit_function;
} }
} }
MmsValue_update(self->ctlVal, ctlVal); MmsValue_update(self->ctlVal, ctlVal);
exit_function:
if (self->analogValue) if (self->analogValue)
MmsValue_setElement(self->analogValue, 0, NULL); MmsValue_setElement(self->analogValue, 0, NULL);
return true; return retVal;
} }
static void static void
@ -857,12 +869,13 @@ ControlObjectClient_selectWithValueAsync(ControlObjectClient self, IedClientErro
} }
else { else {
MmsValue_update(self->ctlVal, ctlVal); MmsValue_update(self->ctlVal, ctlVal);
if (self->analogValue)
MmsValue_setElement(self->analogValue, 0, NULL);
} }
exit_function: exit_function:
if (self->analogValue)
MmsValue_setElement(self->analogValue, 0, NULL);
return invokeId; return invokeId;
} }

Loading…
Cancel
Save