From patchwork Mon Feb 8 19:01:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 44812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A090FB7D0F for ; Tue, 9 Feb 2010 06:04:16 +1100 (EST) Received: from localhost ([127.0.0.1]:40249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeYsm-0000yE-Sj for incoming@patchwork.ozlabs.org; Mon, 08 Feb 2010 14:02:52 -0500 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 To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH 1/4] qjson: Improve debugging X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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; }