From 30f1fecc54cd9ca795c2ddfaca3fae6dc6edba2f Mon Sep 17 00:00:00 2001 From: Ryan Olson Date: Tue, 8 Sep 2015 10:48:58 -0600 Subject: [PATCH] Fix crash from trying to read isa fields as Class pointers on arm64 The isa field is not guaranteed to be a Class pointer on arm64, even though the type encoding indicates that it's a Class pointer. --- Classes/Utility/FLEXRuntimeUtility.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Classes/Utility/FLEXRuntimeUtility.m b/Classes/Utility/FLEXRuntimeUtility.m index 6ebd4708e3..e67e6cc6c7 100644 --- a/Classes/Utility/FLEXRuntimeUtility.m +++ b/Classes/Utility/FLEXRuntimeUtility.m @@ -206,6 +206,13 @@ + (id)valueForIvar:(Ivar)ivar onObject:(id)object { id value = nil; const char *type = ivar_getTypeEncoding(ivar); +#ifdef __arm64__ + // See http://www.sealiesoftware.com/blog/archive/2013/09/24/objc_explain_Non-pointer_isa.html + const char *name = ivar_getName(ivar); + if (type[0] == @encode(Class)[0] && strcmp(name, "isa") != 0) { + value = object_getClass(object); + } else +#endif if (type[0] == @encode(id)[0] || type[0] == @encode(Class)[0]) { value = object_getIvar(object, ivar); } else {