提交 1590d266 编写于 作者: E Eduardo Habkost 提交者: Andreas Färber

qom: strdup() target property name on object_property_add_alias()

With this, object_property_add_alias() callers can safely free the
target property name, like what already happens with the 'name' argument
to all object_property_add*() functions.
Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: NAndreas Färber <afaerber@suse.de>
上级 8ffe756d
...@@ -1705,7 +1705,7 @@ void object_property_add_uint64_ptr(Object *obj, const char *name, ...@@ -1705,7 +1705,7 @@ void object_property_add_uint64_ptr(Object *obj, const char *name,
typedef struct { typedef struct {
Object *target_obj; Object *target_obj;
const char *target_name; char *target_name;
} AliasProperty; } AliasProperty;
static void property_get_alias(Object *obj, struct Visitor *v, void *opaque, static void property_get_alias(Object *obj, struct Visitor *v, void *opaque,
...@@ -1736,6 +1736,7 @@ static void property_release_alias(Object *obj, const char *name, void *opaque) ...@@ -1736,6 +1736,7 @@ static void property_release_alias(Object *obj, const char *name, void *opaque)
{ {
AliasProperty *prop = opaque; AliasProperty *prop = opaque;
g_free(prop->target_name);
g_free(prop); g_free(prop);
} }
...@@ -1763,7 +1764,7 @@ void object_property_add_alias(Object *obj, const char *name, ...@@ -1763,7 +1764,7 @@ void object_property_add_alias(Object *obj, const char *name,
prop = g_malloc(sizeof(*prop)); prop = g_malloc(sizeof(*prop));
prop->target_obj = target_obj; prop->target_obj = target_obj;
prop->target_name = target_name; prop->target_name = g_strdup(target_name);
op = object_property_add(obj, name, prop_type, op = object_property_add(obj, name, prop_type,
property_get_alias, property_get_alias,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册