提交 55f8301f 编写于 作者: A Anthony Liguori

json-streamer: allow recovery after bad input

Once we detect a malformed message, make sure to reset our state.
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 ef749d07
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册