From 9f83f1639f74a1ed4e0913bf6f3546d52f301411 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Fri, 29 Dec 2017 15:34:59 +0000 Subject: [PATCH] Fix traversal of the resolved class list. This probably didn't make a difference, but if we ended up resolving a class as a result of resolving a subclass, then we'd previously go and explore an unrelated linked list for a bit. --- class_table.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/class_table.c b/class_table.c index fa9a876..2942251 100644 --- a/class_table.c +++ b/class_table.c @@ -258,14 +258,24 @@ PRIVATE BOOL objc_resolve_class(Class cls) PRIVATE void objc_resolve_class_links(void) { LOCK_RUNTIME_FOR_SCOPE(); - Class class = unresolved_class_list; BOOL resolvedClass; do { + Class class = unresolved_class_list; resolvedClass = NO; while ((Nil != class)) { Class next = class->unresolved_class_next; + // If the class has been resolved, then this means that the last + // call to objc_resolve_class resolved it as part of resolving + // superclasses and removed it from the list. We now don't have a + // pointer into the linked list, so abort and try again from the + // start. + if (objc_test_class_flag(class, objc_class_flag_resolved)) + { + assert(resolvedClass); + break; + } objc_resolve_class(class); if (resolvedClass || objc_test_class_flag(class, objc_class_flag_resolved))