[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [PATCH v1 1/1] qom: Fix class cast of NULL classes
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-stable] [PATCH v1 1/1] qom: Fix class cast of NULL classes |
Date: |
Tue, 18 Jun 2013 11:53:42 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 |
Il 18/06/2013 11:18, address@hidden ha scritto:
> From: Peter Crosthwaite <address@hidden>
>
> 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 <address@hidden>
Cc: address@hidden
> ---
>
> 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];
> }
>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-stable] [PATCH v1 1/1] qom: Fix class cast of NULL classes,
Paolo Bonzini <=