From: Paolo Bonzini Date: Fri, 3 Feb 2012 14:41:13 +0000 (+0100) Subject: qom: fix off-by-one X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=8f770d39056c797a0a3de7a9a1a00befddfb088a;p=qemu.git qom: fix off-by-one Signed-off-by: Paolo Bonzini --- diff --git a/qom/object.c b/qom/object.c index 212629defd..7fd37cb879 100644 --- a/qom/object.c +++ b/qom/object.c @@ -854,11 +854,8 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, target = object_resolve_path(path, &ambiguous); if (target) { - gchar *target_type; - - target_type = g_strdup(&type[5]); - target_type[strlen(target_type) - 2] = 0; - + /* Go from link to FOO. */ + gchar *target_type = g_strndup(&type[5], strlen(type) - 6); if (object_dynamic_cast(target, target_type)) { object_ref(target); *child = target;