From patchwork Fri Dec 16 12:01:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 131814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1636DB6F9F for ; Fri, 16 Dec 2011 23:02:42 +1100 (EST) Received: from localhost ([::1]:44493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbWUk-0007kl-GQ for incoming@patchwork.ozlabs.org; Fri, 16 Dec 2011 07:02:34 -0500 Received: from eggs.gnu.org ([140.186.70.92]:60606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbWUN-0007MP-JK for qemu-devel@nongnu.org; Fri, 16 Dec 2011 07:02:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbWUG-0006u1-7c for qemu-devel@nongnu.org; Fri, 16 Dec 2011 07:02:11 -0500 Received: from mail-ee0-f45.google.com ([74.125.83.45]:45954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbWUG-0006tv-10 for qemu-devel@nongnu.org; Fri, 16 Dec 2011 07:02:04 -0500 Received: by eekb45 with SMTP id b45so3474531eek.4 for ; Fri, 16 Dec 2011 04:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=5QeyUCTTGWzQBAsHvB4YljGff3RMgfkfHSKM8VoRZ+Y=; b=lfDgWtsQOW4so5bMhXq2oeIKuWUIggK1gz2NieGS8vszNd5VuMTSVKrEeIkhrmug9Z 4pHvdUXXj99PJvBH551Lhe2Cy5+63/98AR6OZLz1kDYwZXxAAPqfm2PyGKZfo0dncvGP VCP/Un7TMdTUZdbvsW99EdSSAC1P5MICd6VM0= Received: by 10.14.126.80 with SMTP id a56mr3110460eei.121.1324036923188; Fri, 16 Dec 2011 04:02:03 -0800 (PST) Received: from localhost.localdomain (93-34-178-147.ip50.fastwebnet.it. [93.34.178.147]) by mx.google.com with ESMTPS id q28sm37245980eea.6.2011.12.16.04.02.02 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Dec 2011 04:02:02 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 16 Dec 2011 13:01:51 +0100 Message-Id: <1324036918-2405-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.7.1 In-Reply-To: <1324036918-2405-1-git-send-email-pbonzini@redhat.com> References: <1324036918-2405-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.83.45 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH 1/8] qapi: fix NULL pointer dereference X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org QAPI currently cannot deal with no object pushed to the stack, and dereferences a NULL pointer. This is visible with qom-get path=/i440fx/piix3 property=romfile after static non-string properties are introduced. Signed-off-by: Paolo Bonzini --- qapi/qmp-output-visitor.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index f76d015..29575da 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -65,13 +65,13 @@ static QObject *qmp_output_pop(QmpOutputVisitor *qov) static QObject *qmp_output_first(QmpOutputVisitor *qov) { QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack); - return e->value; + return e ? e->value : NULL; } static QObject *qmp_output_last(QmpOutputVisitor *qov) { QStackEntry *e = QTAILQ_FIRST(&qov->stack); - return e->value; + return e ? e->value : NULL; } static void qmp_output_add_obj(QmpOutputVisitor *qov, const char *name,