Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NeYre-0000y3-Vc for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:43 -0500 Received: from [199.232.76.173] (port=33459 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeYre-0000xv-GN for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:42 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NeYrc-000364-Px for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:42 -0500 Received: from mx20.gnu.org ([199.232.41.8]:4962) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NeYrc-00035Y-JB for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NeYrb-0005d2-RB for qemu-devel@nongnu.org; Mon, 08 Feb 2010 14:01:40 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o18J1bdv018394 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 8 Feb 2010 14:01:37 -0500 Received: from localhost (vpn-8-125.rdu.redhat.com [10.11.8.125]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o18J1aSt004231 for ; Mon, 8 Feb 2010 14:01:37 -0500 From: Luiz Capitulino Date: Mon, 8 Feb 2010 17:01:27 -0200 Message-Id: <1265655690-6628-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1265655690-6628-1-git-send-email-lcapitulino@redhat.com> References: <1265655690-6628-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 1/4] qjson: Improve debugging List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Add an assert() to qobject_from_jsonf() to assure that the returned QObject is not NULL. Currently this is duplicated in the callers. Signed-off-by: Luiz Capitulino --- qjson.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/qjson.c b/qjson.c index 9ad8a91..483c667 100644 --- a/qjson.c +++ b/qjson.c @@ -53,6 +53,10 @@ QObject *qobject_from_json(const char *string) return qobject_from_jsonv(string, NULL); } +/* + * IMPORTANT: This function aborts on error, thus it must not + * be used with untrusted arguments. + */ QObject *qobject_from_jsonf(const char *string, ...) { QObject *obj; @@ -62,6 +66,7 @@ QObject *qobject_from_jsonf(const char *string, ...) obj = qobject_from_jsonv(string, &ap); va_end(ap); + assert(obj != NULL); return obj; } -- 1.6.6