Permalink
Browse files

Merge pull request #28 from pivotaltracker/master

Fixed memory leaks in expectations and matchers
  • Loading branch information...
2 parents d50b919 + 53259b9 commit abc3d83283fdc3942413e2f3603be6dbb2fe44b8 @petejkim petejkim committed Mar 9, 2013
Showing with 19 additions and 2 deletions.
  1. +10 −0 src/EXPBlockDefinedMatcher.m
  2. +8 −2 src/EXPExpect.m
  3. +1 −0 src/ExpectaSupport.h
@@ -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;
View
@@ -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];
}
@@ -186,9 +192,9 @@ - (NSString *)failureMessageForNotTo:(id)actual
{
__block id blockExpectation = _expectation;
- return [^{
+ return [[^{
[blockExpectation applyMatcher:self];
- } copy];
+ } copy] autorelease];
}
@end
View
@@ -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.