From: Paolo Bonzini <pbonzini@redhat.com>
To: peter.crosthwaite@xilinx.com
Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org,
"1.5.x" <qemu-stable@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v1 1/1] qom: Fix class cast of NULL classes
Date: Tue, 18 Jun 2013 11:53:42 +0200 [thread overview]
Message-ID: <51C02E26.604@redhat.com> (raw)
In-Reply-To: <94cd5ba46b74eea289a7e582635820c1c54e66fa.1371546907.git.peter.crosthwaite@xilinx.com>
Il 18/06/2013 11:18, peter.crosthwaite@xilinx.com ha scritto:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> Its clear from the implementation that class casting is supposed to work
> with a NULL class argument. Guard all dereferences of the class argument
> against NULL accordingly.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: qemu-stable@nongnu.org
> ---
>
> qom/object.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index 803b94b..b7ecb9f 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -531,14 +531,14 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
> #ifdef CONFIG_QOM_CAST_DEBUG
> int i;
>
> - for (i = 0; i < OBJECT_CLASS_CAST_CACHE; i++) {
> + for (i = 0; class && i < OBJECT_CLASS_CAST_CACHE; i++) {
> if (class->cast_cache[i] == typename) {
> ret = class;
> goto out;
> }
> }
> #else
> - if (!class->interfaces) {
> + if (!class || !class->interfaces) {
> return class;
> }
> #endif
> @@ -551,7 +551,7 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
> }
>
> #ifdef CONFIG_QOM_CAST_DEBUG
> - if (ret == class) {
> + if (class && ret == class) {
> for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
> class->cast_cache[i - 1] = class->cast_cache[i];
> }
>
next prev parent reply other threads:[~2013-06-18 9:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 9:18 [Qemu-devel] [PATCH v1 1/1] qom: Fix class cast of NULL classes peter.crosthwaite
2013-06-18 9:53 ` Paolo Bonzini [this message]
2013-07-10 5:17 ` Peter Crosthwaite
2013-07-10 19:33 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51C02E26.604@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).