]> git.proxmox.com Git - qemu.git/commitdiff
json-parser: Fix potential NULL pointer segfault
authorStefan Weil <sw@weilnetz.de>
Mon, 3 Sep 2012 19:19:11 +0000 (21:19 +0200)
committerLuiz Capitulino <lcapitulino@redhat.com>
Wed, 5 Sep 2012 18:48:57 +0000 (15:48 -0300)
Report from smatch:
json-parser.c:474 parse_object(62) error: potential null derefence 'dict'.
json-parser.c:553 parse_array(75) error: potential null derefence 'list'.

Label 'out' in json-parser.c can be called with list == NULL
which is passed to QDECREF.

Modify QDECREF to handle a NULL argument (inline function qobject_decref
already handles them, too).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qobject.h

index d42386dde1394d9651c87d69665ffa2742f4cdea..9124649ed202cc8c256d7ea033aace1e9bb61de5 100644 (file)
--- a/qobject.h
+++ b/qobject.h
@@ -71,7 +71,7 @@ typedef struct QObject {
 
 /* High-level interface for qobject_decref() */
 #define QDECREF(obj)              \
-    qobject_decref(QOBJECT(obj))
+    qobject_decref(obj ? QOBJECT(obj) : NULL)
 
 /* Initialize an object to default values */
 #define QOBJECT_INIT(obj, qtype_type)   \