Commit 55f8301f authored by Anthony Liguori's avatar Anthony Liguori
Browse files

json-streamer: allow recovery after bad input



Once we detect a malformed message, make sure to reset our state.

Signed-off-by: default avatarMichael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent ef749d07
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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();