json: Don't pass null @tokens to json_parser_parse()
commitff281a272f67a07d8ea29ca0350c4a3e0d3de73c
authorMarkus Armbruster <armbru@redhat.com>
Thu, 23 Aug 2018 16:40:02 +0000 (23 18:40 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 24 Aug 2018 18:26:37 +0000 (24 20:26 +0200)
tree9bd823ea679b7188ca9d2185b33394e15c946faa
parent62815d85aed71eff7b6c3a524705180fb04f5d30
json: Don't pass null @tokens to json_parser_parse()

json_parser_parse() normally returns the QObject on success.  Except
it returns null when its @tokens argument is null.

Its only caller json_message_process_token() passes null @tokens when
emitting a lexical error.  The call is a rather opaque way to say json
= NULL then.

Simplify matters by lifting the assignment to json out of the emit
path: initialize json to null, set it to the value of
json_parser_parse() when there's no lexical error.  Drop the special
case from json_parser_parse().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180823164025.12553-36-armbru@redhat.com>
qobject/json-parser.c
qobject/json-streamer.c