Fix an uninitialized memory access in json_pointer.

Add comments describing when the fields of the internal struct json_pointer_get_result are valid.
This commit is contained in:
Eric Hawicz
2023-07-26 18:15:07 -04:00
parent efc530594b
commit a14a3a680c
3 changed files with 16 additions and 16 deletions

View File

@@ -49,9 +49,9 @@ static int json_patch_apply_test(struct json_object **res,
static int __json_patch_apply_remove(struct json_pointer_get_result *jpres)
{
if (json_object_is_type(jpres->parent, json_type_array)) {
return json_object_array_del_idx(jpres->parent, jpres->id.index, 1);
} else if (jpres->parent && jpres->id.key) {
json_object_object_del(jpres->parent, jpres->id.key);
return json_object_array_del_idx(jpres->parent, jpres->index_in_parent, 1);
} else if (jpres->parent && jpres->key_in_parent) {
json_object_object_del(jpres->parent, jpres->key_in_parent);
return 0;
} else {
return json_object_put(jpres->obj);