Skip to content

Commit

Permalink
Fix crash for unsupported property type encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
NSExceptional committed Oct 7, 2021
1 parent afeff1b commit 60e23e1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Classes/Utility/Runtime/FLEXRuntimeUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "FLEXRuntimeUtility.h"
#import "FLEXObjcInternal.h"
#import "FLEXTypeEncodingParser.h"
#import "FLEXMethod.h"

NSString * const FLEXRuntimeUtilityErrorDomain = @"FLEXRuntimeUtilityErrorDomain";

Expand Down Expand Up @@ -332,15 +333,14 @@ + (id)performSelector:(SEL)selector
return nil;
}

NSMethodSignature *methodSignature = [NSMethodSignature signatureWithObjCTypes:({
Method method;
if (object_isClass(object)) {
method = class_getClassMethod(object, selector);
} else {
method = class_getInstanceMethod(object_getClass(object), selector);
}
method_getTypeEncoding(method);
})];
// It is important to use object_getClass and not -class here, as
// object_getClass will return a different result for class objects
Class cls = object_getClass(object);
NSMethodSignature *methodSignature = [FLEXMethod selector:selector class:cls].signature;
if (!methodSignature) {
// Unsupported type encoding
return nil;
}

// Probably an unsupported type encoding, like bitfields.
// In the future, we could calculate the return length
Expand All @@ -362,7 +362,7 @@ + (id)performSelector:(SEL)selector
[invocation retainArguments];

// Always self and _cmd
NSUInteger numberOfArguments = [methodSignature numberOfArguments];
NSUInteger numberOfArguments = methodSignature.numberOfArguments;
for (NSUInteger argumentIndex = kFLEXNumberOfImplicitArgs; argumentIndex < numberOfArguments; argumentIndex++) {
NSUInteger argumentsArrayIndex = argumentIndex - kFLEXNumberOfImplicitArgs;
id argumentObject = arguments.count > argumentsArrayIndex ? arguments[argumentsArrayIndex] : nil;
Expand Down

0 comments on commit 60e23e1

Please sign in to comment.