|
|
@@ -180,12 +180,23 @@ BOOL FLEXPointerIsValidObjcObject(const void *ptr)
|
|
|
// We check if the returned class is readable because object_getClass
|
|
|
// can return a garbage value when given a non-nil pointer to a non-object
|
|
|
Class cls = object_getClass((__bridge id)ptr);
|
|
|
- if (cls && FLEXPointerIsReadable((__bridge void *)cls) && object_isClass(cls)) {
|
|
|
- return YES;
|
|
|
+ if (cls && FLEXPointerIsReadable((__bridge void *)cls)) {
|
|
|
+ // Just because this pointer is readable doesn't mean whatever is at
|
|
|
+ // it's ISA offset is readable. We need to do the same checks on it's ISA.
|
|
|
+ // Even this isn't perfect, because once we call object_isClass, we're
|
|
|
+ // going to dereference a member of the metaclass, which may or may not
|
|
|
+ // be readable itself. For the time being there is no way to access it
|
|
|
+ // to check here, and I have yet to hard-code a solution.
|
|
|
+ Class metaclass = object_getClass(cls);
|
|
|
+ if (metaclass && FLEXPointerIsReadable((__bridge void *)metaclass)) {
|
|
|
+ if (object_isClass(cls)) {
|
|
|
+ return YES;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return NO;
|
|
|
}
|
|
|
|
|
|
|
|
|
-}
|
|
|
+} // End extern "C"
|