Really fix the off-by-one error in json_array_remove()
It didn't affect only the last element but all of them. One item too much was always moved.
This commit is contained in:
@@ -511,7 +511,7 @@ int json_array_remove(json_t *json, size_t index)
|
||||
|
||||
/* If we're removing the last element, nothing has to be moved */
|
||||
if(index < array->entries - 1)
|
||||
array_move(array, index, index + 1, array->entries - index);
|
||||
array_move(array, index, index + 1, array->entries - index - 1);
|
||||
|
||||
array->entries--;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user