Am 30.05.2012 18:19, schrieb Igor Mammedov:
> without assert it will crash at following point:
>    OBJECT_CHECK(type, obj, name) \
>     ((type *)object_dynamic_cast_assert(OBJECT(obj), (name)))
>       =>  object_dynamic_cast(obj, typename)
>         =>  object_is_type(obj, target_type)
>           =>  type_is_ancestor(obj->class->type, target_type);
>                                  ^^^
> so abort earlier and print nice message instead of SIGSEGV
> 
> Signed-off-by: Igor Mammedov <imamm...@redhat.com>

Acked-by: Andreas Färber <afaer...@suse.de>

If nobody objects, I'll queue it on qom-next.

Andreas

> ---
>  qom/object.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index 00bb3b0..444e2fc 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -481,6 +481,8 @@ Object *object_dynamic_cast_assert(Object *obj, const 
> char *typename)
>  {
>      Object *inst;
>  
> +    g_assert(obj != NULL);
> +
>      inst = object_dynamic_cast(obj, typename);
>  
>      if (!inst) {

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

Reply via email to