Skip to content

Commit

Permalink
Fix crash from trying to read isa fields as Class pointers on arm64
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ryanolsonk committed Sep 8, 2015
1 parent 85a424a commit 30f1fec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Classes/Utility/FLEXRuntimeUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 30f1fec

Please sign in to comment.