Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed crash when NSStackBlock was passed as an argument. Now converti…

…ng NSStackBlock to NSMallocBlock.
  • Loading branch information...
commit ccc0c3a30b23e24a3fe14f461680aff19f2561f7 1 parent 1ab52f7
@roustem roustem authored
Showing with 10 additions and 5 deletions.
  1. +2 −0  Kiwi/KWMessagePattern.m
  2. +8 −5 Kiwi/KWStub.m
View
2  Kiwi/KWMessagePattern.m
@@ -80,6 +80,8 @@ + (id)messagePatternFromInvocation:(NSInvocation *)anInvocation {
object = [KWValue valueWithBytes:[data bytes] objCType:type];
}
+
+ if (strcmp(type, "@?") == 0) object = [[object copy] autorelease]; // Converting NSStackBlock to NSMallocBlock
[argumentFilters addObject:(object != nil) ? object : [KWNull null]];
}
}
View
13 Kiwi/KWStub.m
@@ -179,19 +179,22 @@ - (BOOL)processInvocation:(NSInvocation *)anInvocation {
if (block) {
NSUInteger numberOfArguments = [[anInvocation methodSignature] numberOfArguments];
- NSMutableArray *params = [NSMutableArray arrayWithCapacity:(numberOfArguments-2)];
+ NSMutableArray *args = [NSMutableArray arrayWithCapacity:(numberOfArguments-2)];
for (NSUInteger i = 2; i < numberOfArguments; ++i) {
- id param = [anInvocation getArgumentAtIndexAsObject:i];
- [params addObject:param];
+ id arg = [anInvocation getArgumentAtIndexAsObject:i];
+
+ const char *argType = [[anInvocation methodSignature] getArgumentTypeAtIndex:i];
+ if (strcmp(argType, "@?") == 0) arg = [[arg copy] autorelease];
+ [args addObject:arg];
}
- id newValue = block(params);
+ id newValue = block(args);
if (newValue != value) {
[value release];
value = [newValue retain];
}
- [params removeAllObjects]; // We don't want these objects to be in autorelease pool
+ [args removeAllObjects]; // We don't want these objects to be in autorelease pool
}
if (self.value == nil)
Please sign in to comment.
Something went wrong with that request. Please try again.