From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrLtv-0002Cr-Ql for qemu-devel@nongnu.org; Wed, 28 Oct 2015 04:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrLtu-0008Hi-J4 for qemu-devel@nongnu.org; Wed, 28 Oct 2015 04:16:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55355) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrLtu-0008HT-Dc for qemu-devel@nongnu.org; Wed, 28 Oct 2015 04:16:06 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 00DF9ABC for ; Wed, 28 Oct 2015 08:16:05 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9S8G4Xj030640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 28 Oct 2015 04:16:05 -0400 From: Markus Armbruster Date: Wed, 28 Oct 2015 09:15:52 +0100 Message-Id: <1446020161-21758-6-git-send-email-armbru@redhat.com> In-Reply-To: <1446020161-21758-1-git-send-email-armbru@redhat.com> References: <1446020161-21758-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PULL v2 05/14] qlist: Make conversion from QObject * accept null List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org qobject_to_qlist() crashes on null, which is a trap for the unwary. Return null instead. Signed-off-by: Markus Armbruster Message-Id: <1444918537-18107-6-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Luiz Capitulino --- qobject/qlist.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qobject/qlist.c b/qobject/qlist.c index 1ced0de..298003a 100644 --- a/qobject/qlist.c +++ b/qobject/qlist.c @@ -142,10 +142,9 @@ size_t qlist_size(const QList *qlist) */ QList *qobject_to_qlist(const QObject *obj) { - if (qobject_type(obj) != QTYPE_QLIST) { + if (!obj || qobject_type(obj) != QTYPE_QLIST) { return NULL; } - return container_of(obj, QList, base); } -- 2.4.3