All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH] json-parser: Fix potential NULL pointer segfault
@ 2012-09-01 10:52 ` Stefan Weil
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Weil @ 2012-09-01 10:52 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-trivial, Stefan Weil, qemu-devel

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 <sw@weilnetz.de>
---
 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



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-09-03 17:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-01 10:52 [Qemu-trivial] [PATCH] json-parser: Fix potential NULL pointer segfault Stefan Weil
2012-09-01 10:52 ` [Qemu-devel] " Stefan Weil
2012-09-03 16:41 ` [Qemu-trivial] " Luiz Capitulino
2012-09-03 16:41   ` Luiz Capitulino
2012-09-03 16:53   ` [Qemu-trivial] " Stefan Weil
2012-09-03 16:53     ` Stefan Weil
2012-09-03 17:14     ` [Qemu-trivial] " Stefan Weil
2012-09-03 17:14       ` Stefan Weil
2012-09-03 17:54       ` [Qemu-trivial] " Luiz Capitulino
2012-09-03 17:54         ` Luiz Capitulino

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.