diff options
author | Nicolas Williams <nico@cryptonector.com> | 2019-03-26 18:33:19 -0500 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2019-03-26 18:58:55 -0500 |
commit | b52fc1043b045a3c5004be7eb85a15d3a055e9a4 (patch) | |
tree | 4a4d52df749d772dee389041c5988ac1ed51d046 | |
parent | b34af08f676f635a35a41137506715ad8a180105 (diff) |
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.
-rw-r--r-- | src/execute.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/execute.c b/src/execute.c index d7a9615d..65c6bc77 100644 --- a/src/execute.c +++ b/src/execute.c @@ -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; |