Skip to content

Commit

Permalink
Fix jqlang#2051 -- iterate arrays backwards in path ctx
Browse files Browse the repository at this point in the history
In case a path gets deleted, we should iterate arrays backwards in
path/1 context.
  • Loading branch information
nicowilliams committed Jan 31, 2020
1 parent 9fdf955 commit 9c9013b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ jv jq_next(jq_state *jq) {
is_last = idx == len - 1;
if (keep_going) {
key = jv_number(idx);
value = jv_array_get(jv_copy(container), idx);
value = jv_array_get(jv_copy(container), jq->subexp_nest ? idx : len - (idx + 1));
}
} else if (jv_get_kind(container) == JV_KIND_OBJECT) {
if (opcode == EACH || opcode == EACH_OPT) idx = jv_object_iter(container);
Expand Down

0 comments on commit 9c9013b

Please sign in to comment.