From 8c5d5a0effb57b331d5042863dc3b9075dff1088 Mon Sep 17 00:00:00 2001 From: Michael Roth Date: Wed, 1 Jun 2011 12:15:00 -0500 Subject: [PATCH] json-parser: add handling for NULL token list Currently a NULL token list will crash the parser, instead we have it pass back a NULL QObject. Signed-off-by: Michael Roth Signed-off-by: Anthony Liguori --- json-parser.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/json-parser.c b/json-parser.c index 58e973b..849e215 100644 --- a/json-parser.c +++ b/json-parser.c @@ -633,9 +633,13 @@ QObject *json_parser_parse(QList *tokens, va_list *ap) QObject *json_parser_parse_err(QList *tokens, va_list *ap, Error **errp) { JSONParserContext ctxt = {}; - QList *working = qlist_copy(tokens); + QList *working; QObject *result; + if (!tokens) { + return NULL; + } + working = qlist_copy(tokens); result = parse_value(&ctxt, &working, ap); QDECREF(working); -- 2.7.4