Marc-André Lureau <marcandre.lur...@redhat.com> writes: > An unterminated string will make parser emit an error (tokens == > NULL). Let's report it. > > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > qobject/qjson.c | 3 +++ > tests/check-qjson.c | 6 +++--- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/qobject/qjson.c b/qobject/qjson.c > index 8a9d116150..01218c9ad6 100644 > --- a/qobject/qjson.c > +++ b/qobject/qjson.c > @@ -37,6 +37,9 @@ static void parse_json(JSONMessageParser *parser, GQueue > *tokens) > { > JSONParsingState *s = container_of(parser, JSONParsingState, parser); > > + if (!tokens && !s->err) { > + error_setg(&s->err, QERR_JSON_PARSING); > + } > if (s->result || s->err) { > if (s->result) { > qobject_unref(s->result);
This doesn't fix the JSON parser, it "fixes" one of its users! Other users remain broken. Reproducer for QMP (already mentioned in my review of the previous patch): $ echo -e '{ "execute": "qmp_capabilities" }\n{ "execute": "query-name" }\n"unterminated' | socat UNIX:test-qmp STDIO {"QMP": {"version": {"qemu": {"micro": 90, "minor": 12, "major": 2}, "package": "v3.0.0-rc1-20-g6a024cd461"}, "capabilities": ["oob"]}} {"return": {}} {"return": {}} Note there's no error reported for the last line. The simplification of the JSON parser I have in mind might make this easy to fix properly. I'll look into it. [...]