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>
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();