object_resolve_link() finds the property, then extracts the QOM type from its member @type. @type must be like "link<T>", or else the extraction produces crap, and may read beyond the buffer. This is actually ensured by the users of object_set_link_property(). Simpler: use new member @qom_type instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- qom/object.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/qom/object.c b/qom/object.c index 47e5979aa06..14fd2f3d17e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2010,14 +2010,10 @@ Object *object_resolve_and_typecheck(const char *path, const char *name, static Object *object_resolve_link(Object *obj, const char *name, const char *path, Error **errp) { - const char *type; - g_autofree char *target_type = NULL; + ObjectProperty *prop = object_property_find(obj, name); - /* Go from link<FOO> to FOO. */ - ObjectProperty *prop = object_property_find_err(obj, name, NULL); - type = prop ? prop->type : NULL; - target_type = g_strndup(&type[5], strlen(type) - 6); - return object_resolve_and_typecheck(path, name, target_type, errp); + assert(prop->qom_type); + return object_resolve_and_typecheck(path, name, prop->qom_type, errp); } static void object_set_link_property(Object *obj, Visitor *v, -- 2.55.0