Skip to content

Commit

Permalink
Merge pull request #28 from pivotaltracker/master
Browse files Browse the repository at this point in the history
Fixed memory leaks in expectations and matchers
  • Loading branch information
petejkim committed Mar 9, 2013
2 parents d50b919 + 53259b9 commit abc3d83
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/EXPBlockDefinedMatcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@

@implementation EXPBlockDefinedMatcher

- (void)dealloc
{
self.prerequisiteBlock = nil;
self.matchBlock = nil;
self.failureMessageForToBlock = nil;
self.failureMessageForNotToBlock = nil;

[super dealloc];
}

@synthesize prerequisiteBlock;
@synthesize matchBlock;
@synthesize failureMessageForToBlock;
Expand Down
10 changes: 8 additions & 2 deletions src/EXPExpect.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ - (id)initWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)
return self;
}

- (void)dealloc
{
self.actualBlock = nil;
[super dealloc];
}

+ (EXPExpect *)expectWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(char *)fileName {
return [[[EXPExpect alloc] initWithActualBlock:actualBlock testCase:(id)testCase lineNumber:lineNumber fileName:fileName] autorelease];
}
Expand Down Expand Up @@ -186,9 +192,9 @@ - (NSString *)failureMessageForNotTo:(id)actual
{
__block id blockExpectation = _expectation;

return [^{
return [[^{
[blockExpectation applyMatcher:self];
} copy];
} copy] autorelease];
}

@end
1 change: 1 addition & 0 deletions src/ExpectaSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ EXPFixCategoriesBug(EXPMatcher##matcherName##Matcher); \
} \
[self applyMatcher:matcher to:&actual]; \
}; \
[matcher release]; \
return [[matcherBlock copy] autorelease]; \
} \
@end

0 comments on commit abc3d83

Please sign in to comment.