qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] qom: add error handler for object_property_


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH 1/2] qom: add error handler for object_property_print()
Date: Tue, 23 Sep 2014 15:16:09 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0

Hi,

Am 23.09.2014 um 05:25 schrieb address@hidden:
> From: Gonglei <address@hidden>
> 
> Avoid the caller of object_property_print() leaking string
> argument's memory, such as qdev_print_props() when
> encounter errors.
> 
> Cc: Paolo Bonzini <address@hidden>
> Signed-off-by: Gonglei <address@hidden>
> ---
>  qom/object.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index da0919a..74779e6 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1010,11 +1010,19 @@ char *object_property_print(Object *obj, const char 
> *name, bool human,
>                              Error **errp)
>  {
>      StringOutputVisitor *mo;
> -    char *string;
> +    char *string = NULL;
> +    Error *local_err = NULL;
>  
>      mo = string_output_visitor_new(human);
> -    object_property_get(obj, string_output_get_visitor(mo), name, errp);
> +    object_property_get(obj, string_output_get_visitor(mo), name, 
> &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        goto fail;
> +    }
> +
>      string = string_output_get_string(mo);
> +
> +fail:

Permission to rename the label to "out" as in 2/2?

Series looks good otherwise.

Regards,
Andreas

>      string_output_visitor_cleanup(mo);
>      return string;
>  }
> 


-- 
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

[Prev in Thread] Current Thread [Next in Thread]