aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorHervé Poussineau <hpoussin@reactos.org>2013-12-03 16:42:00 +0100
committerAndreas Färber <afaerber@suse.de>2013-12-24 18:02:10 +0100
commitf54c19cacb44d2fad14aca6be08e4aa9b8423217 (patch)
tree73aa3322a25995311d6780c8acb5335e20be7778 /qom
parent14389dbd0281e901176319f5868166c706485c5e (diff)
qom: Detect bad reentrance during object_class_foreach()
We should not modify the type hash table while it is being iterated on. Assert that it does not happen. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c
index 470a1ac86d..2aab30b32f 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -78,8 +78,11 @@ static GHashTable *type_table_get(void)
return type_table;
}
+static bool enumerating_types;
+
static void type_table_add(TypeImpl *ti)
{
+ assert(!enumerating_types);
g_hash_table_insert(type_table_get(), (void *)ti->name, ti);
}
@@ -670,7 +673,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
{
OCFData data = { fn, implements_type, include_abstract, opaque };
+ enumerating_types = true;
g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data);
+ enumerating_types = false;
}
int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),