Replace static allocation with a runtime check
@@ -83,8 +83,12 @@ static BOOL blockIsCompatibleWithMethodType(id block, const char *methodType){
char *quotePtr = strchr(blockType+2, '"');
if (NULL != quotePtr) {
++quotePtr;
- NSCAssert(strlen(quotePtr) + 2 < 1024, @"Method signatures over 1KB are not supported");
- char filteredType[1024];
+ size_t filterTypeLen = strlen(quotePtr) + 2;
+ if (strlen(quotePtr) > filterTypeLen) { // integer overflow check
+ NSCAssert(false, @"Method signature is too long to swizzle");
+ return NO;
+ }
+ char filteredType[filterTypeLen];
memset(filteredType, 0, sizeof(filteredType));
*filteredType = '@';
strncpy(filteredType + 1, quotePtr, sizeof(filteredType) - 2);
