From 41e9ca891593240330418ec52e7d9fb59693ad57 Mon Sep 17 00:00:00 2001 From: Slipp Douglas Thompson Date: Sun, 9 Feb 2014 18:02:27 -0500 Subject: [PATCH] Fixed memory leaks pointed out by Clang MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed potential memory leaks pointed out by the Clang static analyzer: • DTMultiExpressionPatch#compileSourceOfType:, `QCMathematicalExpression *expr` is released properly… unless the `error` condition is hit.  Now `release`s before `continue`ing in the error case. • DTSampleHoldPatch#setState: The result of NSKeyedUnarchiver#unarchiveObjectWithData: is double-retained, once explicitly and then again by the retaining `priorValue` property.  Removed the explicit retain. --- DTMultiExpressionPatch.m | 1 + DTSampleHoldPatch.m | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DTMultiExpressionPatch.m b/DTMultiExpressionPatch.m index 97a84d5..9df162b 100644 --- a/DTMultiExpressionPatch.m +++ b/DTMultiExpressionPatch.m @@ -228,6 +228,7 @@ - (id)compileSourceOfType:(NSString *)sourceType // @"line" key is the line number to highlight (starts at 1, not zero ... Dijkstra would be pissed...) [errors setObject:[NSNumber numberWithUnsignedInt:lineNumber] forKey:@"line"]; } + [expr release]; continue; } diff --git a/DTSampleHoldPatch.m b/DTSampleHoldPatch.m index 008732d..2f14339 100644 --- a/DTSampleHoldPatch.m +++ b/DTSampleHoldPatch.m @@ -114,7 +114,7 @@ - (BOOL)setState:(NSDictionary*)state { NSData *d = [state objectForKey:@"data"]; if(d) - self.priorValue = [[NSKeyedUnarchiver unarchiveObjectWithData:d] retain]; + self.priorValue = [NSKeyedUnarchiver unarchiveObjectWithData:d]; return [super setState:state]; }