[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/7] qom: add error handler for object_property_p
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH v2 1/7] qom: add error handler for object_property_print() |
Date: |
Thu, 25 Sep 2014 10:04:16 +0800 |
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>
Reviewed-by: Paolo Bonzini <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..21135e1 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;
}
--
1.7.12.4
- [Qemu-devel] [PATCH v2 0/7] add description field in ObjectProperty and PropertyInfo struct, arei.gonglei, 2014/09/24
- [Qemu-devel] [PATCH v2 1/7] qom: add error handler for object_property_print(),
arei.gonglei <=
- [Qemu-devel] [PATCH v2 7/7] qdev: drop legacy_name from qdev properties, arei.gonglei, 2014/09/24
- [Qemu-devel] [PATCH v2 6/7] qmp: print descriptions of object properties, arei.gonglei, 2014/09/24
- [Qemu-devel] [PATCH v2 2/7] qom: add error handler for object alias property, arei.gonglei, 2014/09/24
- [Qemu-devel] [PATCH v2 3/7] qdev: add description field in PropertyInfo struct, arei.gonglei, 2014/09/24
- [Qemu-devel] [PATCH v2 5/7] qdev: set the object property's description to the qdev property's., arei.gonglei, 2014/09/24
- [Qemu-devel] [PATCH v2 4/7] qom: add description field in ObjectProperty struct, arei.gonglei, 2014/09/24