From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeksF-00016o-VD for qemu-devel@nongnu.org; Tue, 21 May 2013 07:37:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UeksA-0002eQ-VF for qemu-devel@nongnu.org; Tue, 21 May 2013 07:36:59 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53612 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeksA-0002eI-O4 for qemu-devel@nongnu.org; Tue, 21 May 2013 07:36:54 -0400 Message-ID: <519B5C52.60802@suse.de> Date: Tue, 21 May 2013 13:36:50 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable 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 Cc: edgar.iglesias@gmail.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, Paolo Bonzini Am 21.05.2013 08:05, schrieb peter.crosthwaite@xilinx.com: > From: Peter Crosthwaite >=20 > object_dymamic_cast_assert used to be tolerant of NULL objects and not "dynamic" > assert. Its clear from the implementation that this is the expected "It's" > behavior. >=20 > 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. >=20 > Signed-off-by: Peter Crosthwaite Otherwise, Reviewed-by: Andreas F=E4rber Andreas > --- >=20 > qom/object.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > 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, con= st char *typename, > int i; > Object *inst; > =20 > - for (i =3D 0; i < OBJECT_CLASS_CAST_CACHE; i++) { > + for (i =3D 0; obj && i < OBJECT_CLASS_CAST_CACHE; i++) { > if (obj->class->cast_cache[i] =3D=3D typename) { > goto out; > } > @@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, con= st char *typename, > =20 > assert(obj =3D=3D inst); > =20 > - if (obj =3D=3D inst) { > + if (obj && obj =3D=3D inst) { > for (i =3D 1; i < OBJECT_CLASS_CAST_CACHE; i++) { > obj->class->cast_cache[i - 1] =3D obj->class->cast_cache[i= ]; > } >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg