diff options
author | Gonglei <arei.gonglei@huawei.com> | 2014-09-27 13:13:55 +0800 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2014-10-15 05:02:55 +0200 |
commit | 3a53009fa044a554dbdeacf30a6b8ea3eb02fe63 (patch) | |
tree | 4e76b4e57a34a2544c9172f348428ab22436c13b | |
parent | 688b057aece53003f9d5a1dadc8961482dc2d948 (diff) | |
download | qemu-3a53009fa044a554dbdeacf30a6b8ea3eb02fe63.zip |
qom: Add error handler for object_property_print()
Avoid the caller of object_property_print() leaking string
argument's memory, such as qdev_print_props() when
encounter errors.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
-rw-r--r-- | qom/object.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/qom/object.c b/qom/object.c index da0919a3dd..21135e1a08 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 out; + } + string = string_output_get_string(mo); + +out: string_output_visitor_cleanup(mo); return string; } |