|
From: | Stefan Weil |
Subject: | Re: [Qemu-trivial] [Qemu-devel] [PATCH] json-parser: Fix potential NULL pointer segfault |
Date: | Mon, 03 Sep 2012 18:53:38 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 |
Am 03.09.2012 18:41, schrieb Luiz Capitulino:
On Sat, 1 Sep 2012 12:52:58 +0200 Stefan Weil <address@hidden> wrote: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); + }I prefer changing QDECREF() to a nop if obj is NULL.
That's fine for me, too. If everybody agrees, I'll send two new patches: one to change QDECREF, one to remove the if statements from other code locations which use the same pattern as my original patch. Cheers, - sw
[Prev in Thread] | Current Thread | [Next in Thread] |