Skip to content

Commit

Permalink
Setup path correctly after stream parsing a key:value object pair (#2642
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wader committed Jul 4, 2023
1 parent 7d424fd commit dfd440f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/jv_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static pfunc stream_token(struct jv_parser* p, char ch) {
p->output = JV_ARRAY(jv_copy(p->path), p->next);
p->next = jv_invalid();
}
p->path = jv_array_set(p->path, p->stacklen - 1, jv_true()); // ready for another name:value pair
p->path = jv_array_set(p->path, p->stacklen - 1, jv_null()); // ready for another key:value pair
p->last_seen = JV_LAST_COMMA;
} else {
assert(k == JV_KIND_NULL);
Expand Down
4 changes: 4 additions & 0 deletions tests/shtest
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ else
echo "Not doing torture tests"
fi

## Regression test for issue #2378 assert when stream parse broken object pair
echo '{"a":1,"b",' | $JQ --stream > /dev/null 2> $d/err
grep 'Objects must consist of key:value pairs' $d/err > /dev/null

## Fuzz parser

## XXX With a $(urandom) builtin we could move this test into tests/all.test
Expand Down

0 comments on commit dfd440f

Please sign in to comment.