mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 20:33:54 -06:00
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 <mdroth@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
5e2dafeb19
commit
c1990ebfa1
1 changed files with 5 additions and 1 deletions
|
@ -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)
|
QObject *json_parser_parse_err(QList *tokens, va_list *ap, Error **errp)
|
||||||
{
|
{
|
||||||
JSONParserContext ctxt = {};
|
JSONParserContext ctxt = {};
|
||||||
QList *working = qlist_copy(tokens);
|
QList *working;
|
||||||
QObject *result;
|
QObject *result;
|
||||||
|
|
||||||
|
if (!tokens) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
working = qlist_copy(tokens);
|
||||||
result = parse_value(&ctxt, &working, ap);
|
result = parse_value(&ctxt, &working, ap);
|
||||||
|
|
||||||
QDECREF(working);
|
QDECREF(working);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue