From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8daK-0005Wm-60 for qemu-devel@nongnu.org; Mon, 03 Sep 2012 16:49:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8daI-0007L0-OT for qemu-devel@nongnu.org; Mon, 03 Sep 2012 16:49:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8daI-0007Kn-GF for qemu-devel@nongnu.org; Mon, 03 Sep 2012 16:49:26 -0400 Date: Mon, 3 Sep 2012 17:50:12 -0300 From: Luiz Capitulino Message-ID: <20120903175012.045303ba@doriath.home> In-Reply-To: <1346699951-27559-1-git-send-email-sw@weilnetz.de> References: <1346699951-27559-1-git-send-email-sw@weilnetz.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] json-parser: Fix potential NULL pointer segfault List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: qemu-devel@nongnu.org On Mon, 3 Sep 2012 21:19:11 +0200 Stefan Weil 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' 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 Applied to qmp-next branch, thanks! > --- > > I did not change QINCREF because there are currently no errors caused > by that rarely used macro. > > This patch can be used instead of the previous patch which fixed > the problem directly in json-parser.c > (see http://patchwork.ozlabs.org/patch/181129/). > > Regards, > Stefan Weil > > qobject.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/qobject.h b/qobject.h > index d42386d..9124649 100644 > --- 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) \