From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf2LZ-0008AP-Jg for qemu-devel@nongnu.org; Wed, 22 May 2013 02:16:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uf2LU-0005qB-N7 for qemu-devel@nongnu.org; Wed, 22 May 2013 02:16:25 -0400 Received: from mail-ee0-f51.google.com ([74.125.83.51]:53299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf2LU-0005pw-GR for qemu-devel@nongnu.org; Wed, 22 May 2013 02:16:20 -0400 Received: by mail-ee0-f51.google.com with SMTP id e51so882299eek.10 for ; Tue, 21 May 2013 23:16:19 -0700 (PDT) Date: Wed, 22 May 2013 08:16:09 +0200 From: "Edgar E. Iglesias" Message-ID: <20130522061608.GH4051@smtp.vpn> References: <8e2bef6a55753869c50bfa32226f7fcf0439ca62.1369183592.git.peter.crosthwaite@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8e2bef6a55753869c50bfa32226f7fcf0439ca62.1369183592.git.peter.crosthwaite@xilinx.com> Subject: Re: [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.crosthwaite@xilinx.com Cc: pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, afaerber@suse.de On Wed, May 22, 2013 at 11:19:16AM +1000, peter.crosthwaite@xilinx.com wrote: > From: Peter Crosthwaite > > object_dynamic_cast_assert used to be tolerant of NULL objects and not > assert. It's clear from the implementation that this is the expected > behavior. > > The preceding check of the cast cache dereferences obj however causing > a segfault. Fix by conditionalizing the cast cache logic on obj being > non-null. > > Signed-off-by: Peter Crosthwaite > Reviewed-by: Andreas Färber > Reviewed-by: Anthony Liguori Reviewed-by: Edgar E. Iglesias > --- > Changed from v1: Fixed 2 commit msg typos (AF review) > > qom/object.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/qom/object.c b/qom/object.c > index ec88231..803b94b 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -442,7 +442,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename, > int i; > Object *inst; > > - for (i = 0; i < OBJECT_CLASS_CAST_CACHE; i++) { > + for (i = 0; obj && i < OBJECT_CLASS_CAST_CACHE; i++) { > if (obj->class->cast_cache[i] == typename) { > goto out; > } > @@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename, > > assert(obj == inst); > > - if (obj == inst) { > + if (obj && obj == inst) { > for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) { > obj->class->cast_cache[i - 1] = obj->class->cast_cache[i]; > } > -- > 1.8.3.rc1.44.gb387c77.dirty >