summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Wadman <mattias.wadman@gmail.com>2023-07-04 21:23:52 +0200
committerGitHub <noreply@github.com>2023-07-05 04:23:52 +0900
commitdfd440f0deae4df056ea8c3a7b216b357ee2f324 (patch)
tree1540a20cd54121c6564101c31a3d8d754c91226f
parent7d424fd52ea9ea642dbb3283c07314fa3cbb550d (diff)
Setup path correctly after stream parsing a key:value object pair (#2642)
-rw-r--r--src/jv_parse.c2
-rwxr-xr-xtests/shtest4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/jv_parse.c b/src/jv_parse.c
index 9ced9f6d..e91f65d0 100644
--- a/src/jv_parse.c
+++ b/src/jv_parse.c
@@ -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);
diff --git a/tests/shtest b/tests/shtest
index 4a4f855a..4cffb1f8 100755
--- a/tests/shtest
+++ b/tests/shtest
@@ -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