qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-trivial] [PATCH] json-parser: Fix potential NULL pointer segfault


From: Stefan Weil
Subject: [Qemu-trivial] [PATCH] json-parser: Fix potential NULL pointer segfault
Date: Sat, 1 Sep 2012 12:52:58 +0200

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 can be called with list == NULL.

Signed-off-by: Stefan Weil <address@hidden>
---
 json-parser.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/json-parser.c b/json-parser.c
index 457291b..c31c759 100644
--- a/json-parser.c
+++ b/json-parser.c
@@ -471,7 +471,9 @@ static QObject *parse_object(JSONParserContext *ctxt, 
va_list *ap)
 
 out:
     parser_context_restore(ctxt, saved_ctxt);
-    QDECREF(dict);
+    if (dict) {
+        QDECREF(dict);
+    }
     return NULL;
 }
 
@@ -550,7 +552,9 @@ static QObject *parse_array(JSONParserContext *ctxt, 
va_list *ap)
 
 out:
     parser_context_restore(ctxt, saved_ctxt);
-    QDECREF(list);
+    if (list) {
+        QDECREF(list);
+    }
     return NULL;
 }
 
-- 
1.7.10




reply via email to

[Prev in Thread] Current Thread [Next in Thread]