From 9ab880b3a2f4b80bd5d8b18a312b3afed65dc036 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 30 Apr 2013 15:02:16 +0200 Subject: QOM: Fail casts for unknown types When we try to cast an object to an unknown type, fail the cast. Today we would simply run into an assert(). This fixes a bug on qemu-system-s390x for me that gets triggered by the audio code looking for PCI and ISA buses. Signed-off-by: Alexander Graf Reviewed-by: Paolo Bonzini Message-id: 1367326936-28539-1-git-send-email-agraf@suse.de Signed-off-by: Anthony Liguori --- qom/object.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'qom/object.c') diff --git a/qom/object.c b/qom/object.c index dd53d242a5..75e6aac15f 100644 --- a/qom/object.c +++ b/qom/object.c @@ -453,6 +453,11 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, TypeImpl *type = class->type; ObjectClass *ret = NULL; + if (!target_type) { + /* target class type unknown, so fail the cast */ + return NULL; + } + if (type->class->interfaces && type_is_ancestor(target_type, type_interface)) { int found = 0; -- cgit v1.2.3