cJSONUtils_ApplyPatches: Fail if removal failed

This commit is contained in:
Max Bruckner 2017-04-12 10:44:29 +02:00
parent a1602f484b
commit 8efb287ae2

View File

@ -456,10 +456,15 @@ static int cJSONUtils_ApplyPatch(cJSON *object, cJSON *patch)
if ((opcode == 1) || (opcode == 2))
{
/* Get rid of old. */
cJSON_Delete(cJSONUtils_PatchDetach(object, (unsigned char*)path->valuestring));
cJSON *old_item = cJSONUtils_PatchDetach(object, (unsigned char*)path->valuestring);
if (old_item == NULL)
{
return 13;
}
cJSON_Delete(old_item);
if (opcode == 1)
{
/* For Remove, this is job done. */
/* For Remove, this job is done. */
return 0;
}
}