Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…ng NSStackBlock to NSMallocBlock.
  • Loading branch information...
commit ccc0c3a30b23e24a3fe14f461680aff19f2561f7 1 parent 1ab52f7
Roustem Karimov roustem authored

Showing 2 changed files with 10 additions and 5 deletions. Show diff stats Hide diff stats

  1. +2 0  Kiwi/KWMessagePattern.m
  2. +8 5 Kiwi/KWStub.m
2  Kiwi/KWMessagePattern.m
@@ -80,6 +80,8 @@ + (id)messagePatternFromInvocation:(NSInvocation *)anInvocation {
80 80 object = [KWValue valueWithBytes:[data bytes] objCType:type];
81 81 }
82 82
  83 +
  84 + if (strcmp(type, "@?") == 0) object = [[object copy] autorelease]; // Converting NSStackBlock to NSMallocBlock
83 85 [argumentFilters addObject:(object != nil) ? object : [KWNull null]];
84 86 }
85 87 }
13 Kiwi/KWStub.m
@@ -179,19 +179,22 @@ - (BOOL)processInvocation:(NSInvocation *)anInvocation {
179 179
180 180 if (block) {
181 181 NSUInteger numberOfArguments = [[anInvocation methodSignature] numberOfArguments];
182   - NSMutableArray *params = [NSMutableArray arrayWithCapacity:(numberOfArguments-2)];
  182 + NSMutableArray *args = [NSMutableArray arrayWithCapacity:(numberOfArguments-2)];
183 183 for (NSUInteger i = 2; i < numberOfArguments; ++i) {
184   - id param = [anInvocation getArgumentAtIndexAsObject:i];
185   - [params addObject:param];
  184 + id arg = [anInvocation getArgumentAtIndexAsObject:i];
  185 +
  186 + const char *argType = [[anInvocation methodSignature] getArgumentTypeAtIndex:i];
  187 + if (strcmp(argType, "@?") == 0) arg = [[arg copy] autorelease];
  188 + [args addObject:arg];
186 189 }
187 190
188   - id newValue = block(params);
  191 + id newValue = block(args);
189 192 if (newValue != value) {
190 193 [value release];
191 194 value = [newValue retain];
192 195 }
193 196
194   - [params removeAllObjects]; // We don't want these objects to be in autorelease pool
  197 + [args removeAllObjects]; // We don't want these objects to be in autorelease pool
195 198 }
196 199
197 200 if (self.value == nil)

0 comments on commit ccc0c3a

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