From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UelJd-0003oB-65 for qemu-devel@nongnu.org; Tue, 21 May 2013 08:05:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UelJb-00057F-Mg for qemu-devel@nongnu.org; Tue, 21 May 2013 08:05:17 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:42217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UelFj-0003hi-5S for qemu-devel@nongnu.org; Tue, 21 May 2013 08:01:15 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 21 May 2013 21:58:43 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id CB9672BB0023 for ; Tue, 21 May 2013 22:01:09 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4LBl2XR23658606 for ; Tue, 21 May 2013 21:47:02 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4LC18bL020858 for ; Tue, 21 May 2013 22:01:09 +1000 From: Anthony Liguori In-Reply-To: References: Date: Tue, 21 May 2013 07:01:04 -0500 Message-ID: <871u90czjy.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v1 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, qemu-devel@nongnu.org Cc: edgar.iglesias@gmail.com peter.crosthwaite@xilinx.com writes: > From: Peter Crosthwaite > > object_dymamic_cast_assert used to be tolerant of NULL objects and not > assert. Its 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: Anthony Liguori Regards, Anthony Liguori > --- > > 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