Skip to content
Browse files

Fixed ARC-related malloc crash.

  • Loading branch information...
1 parent 5aeafcc commit 717913633829f8ed9a07f4b7dfd4d63f950112bc @logancollins committed Aug 7, 2012
Showing with 5 additions and 12 deletions.
  1. +0 −8 Mocha.xcodeproj/project.pbxproj
  2. +5 −4 Mocha/Utilities/MOUtilities.m
View
8 Mocha.xcodeproj/project.pbxproj
@@ -592,13 +592,6 @@
path = JavaScriptCore;
sourceTree = "<group>";
};
- EA78AF5E15D0CE17000A01A9 /* Libraries */ = {
- isa = PBXGroup;
- children = (
- );
- path = Libraries;
- sourceTree = "<group>";
- };
EAA34FCA15647AD700B62244 /* libMocha (iOS) */ = {
isa = PBXGroup;
children = (
@@ -670,7 +663,6 @@
02112329155D99CA00415471 /* BridgeSupport */,
EAA45E68155E5E2200F93E40 /* Utilities */,
EAC8BFCB155F42D3003653BA /* Categories */,
- EA78AF5E15D0CE17000A01A9 /* Libraries */,
EAA45E0D155CE44B00F93E40 /* Supporting Files */,
);
path = Mocha;
View
9 Mocha/Utilities/MOUtilities.m
@@ -286,7 +286,7 @@ JSValueRef MOFunctionInvoke(id function, JSContextRef ctx, size_t argumentCount,
JSValueRef value = NULL;
BOOL objCCall = NO;
BOOL blockCall = NO;
- NSArray *argumentEncodings = nil;
+ NSMutableArray *argumentEncodings = nil;
MOFunctionArgument *returnValue = nil;
void* callAddress = NULL;
NSUInteger callAddressArgumentCount = 0;
@@ -347,7 +347,7 @@ JSValueRef MOFunctionInvoke(id function, JSContextRef ctx, size_t argumentCount,
}
const char *encoding = method_getTypeEncoding(method);
- argumentEncodings = MOParseObjCMethodEncoding(encoding);
+ argumentEncodings = [MOParseObjCMethodEncoding(encoding) mutableCopy];
if (argumentEncodings == nil) {
NSException *e = [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"Unable to parse method encoding for method %@ of class %@", NSStringFromSelector(selector), [target class]] userInfo:nil];
@@ -390,7 +390,7 @@ JSValueRef MOFunctionInvoke(id function, JSContextRef ctx, size_t argumentCount,
callAddress = [function callAddress];
const char *typeEncoding = [(MOClosure *)function typeEncoding];
- argumentEncodings = MOParseObjCMethodEncoding(typeEncoding);
+ argumentEncodings = [MOParseObjCMethodEncoding(typeEncoding) mutableCopy];
if (argumentEncodings == nil) {
NSException *e = [NSException exceptionWithName:MORuntimeException reason:[NSString stringWithFormat:@"Unable to parse method encoding for method %@ of class %@", NSStringFromSelector(selector), [target class]] userInfo:nil];
@@ -470,7 +470,7 @@ JSValueRef MOFunctionInvoke(id function, JSContextRef ctx, size_t argumentCount,
[args addObject:arg];
}
- argumentEncodings = [args copy];
+ argumentEncodings = [args mutableCopy];
// Function arguments are all arguments minus return value
callAddressArgumentCount = [args count] - 1;
@@ -531,6 +531,7 @@ JSValueRef MOFunctionInvoke(id function, JSContextRef ctx, size_t argumentCount,
if (variadic && i >= callAddressArgumentCount) {
arg = [[MOFunctionArgument alloc] init];
[arg setTypeEncoding:_C_ID];
+ [argumentEncodings addObject:arg];
}
else {
arg = [argumentEncodings objectAtIndex:(j + 1)];

0 comments on commit 7179136

Please sign in to comment.
Something went wrong with that request. Please try again.