mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Fix assert in generator subexpressions (fix #1875)
Expressions of the form `path(EXPR) | select(GENERATOR)`, where `EXPR` is a path expression and `GENERATOR` is a generator conditional expression (e.g., `has("a"), has("b")`) cause an assertion if the jq_state VM is torn down too soon. That assert() was only correct if assuming that the conditional is not a generator. If the conditional is generator, then what we see is that when backtracking a SUBEXP_END is executed without a corresponding SUBEXP_BEGIN because the entire conditional is bracketed with SUBEXP_BEGIN and SUBEXP_END, and since it's resumed in the middle, in between the brackets. Rather than assert that the jq->path_len being restored has some particular value, we can simply re-compute it from the restored jq->path.
This commit is contained in:
@@ -292,7 +292,7 @@ uint16_t* stack_restore(jq_state *jq){
|
||||
assert(path_len >= 0);
|
||||
jq->path = jv_array_slice(jq->path, 0, path_len);
|
||||
} else {
|
||||
assert(path_len == 0);
|
||||
fork->path_len = 0;
|
||||
}
|
||||
jv_free(jq->value_at_path);
|
||||
jq->value_at_path = fork->value_at_path;
|
||||
|
Reference in New Issue
Block a user