json-streamer: allow recovery after bad input
Once we detect a malformed message, make sure to reset our state. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
ef749d07e7
commit
55f8301f76
@ -51,8 +51,12 @@ static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTok
|
||||
|
||||
qlist_append(parser->tokens, dict);
|
||||
|
||||
if (parser->brace_count == 0 &&
|
||||
parser->bracket_count == 0) {
|
||||
if (parser->brace_count < 0 ||
|
||||
parser->bracket_count < 0 ||
|
||||
(parser->brace_count == 0 &&
|
||||
parser->bracket_count == 0)) {
|
||||
parser->brace_count = 0;
|
||||
parser->bracket_count = 0;
|
||||
parser->emit(parser, parser->tokens);
|
||||
QDECREF(parser->tokens);
|
||||
parser->tokens = qlist_new();
|
||||
|
Loading…
Reference in New Issue
Block a user