From 5ffd537ef0542e87b42e7d098b6ecf02e832cd14 Mon Sep 17 00:00:00 2001 From: Matt Palcic Date: Wed, 29 Jan 2014 15:50:41 -0500 Subject: [PATCH] Fix some leaks and an uninitialized variable, based on warnings from the clang analyzer. --- Classes/ProgressViews/M13ProgressViewBorderedBar.m | 2 +- Classes/ProgressViews/M13ProgressViewSegmentedBar.m | 8 ++++++++ Classes/ProgressViews/M13ProgressViewSegmentedRing.m | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Classes/ProgressViews/M13ProgressViewBorderedBar.m b/Classes/ProgressViews/M13ProgressViewBorderedBar.m index 91ed86c..afecb2b 100644 --- a/Classes/ProgressViews/M13ProgressViewBorderedBar.m +++ b/Classes/ProgressViews/M13ProgressViewBorderedBar.m @@ -406,7 +406,7 @@ } //Draw the path - CGRect rect; + CGRect rect = CGRectZero; if (_progressDirection == M13ProgressViewBorderedBarProgressDirectionLeftToRight) { rect = CGRectMake(_borderWidth * 2, _borderWidth * 2, (self.bounds.size.width - (4 * _borderWidth)) * self.progress, self.bounds.size.height - (4 * _borderWidth)); } else if (_progressDirection == M13ProgressViewBorderedBarProgressDirectionRightToLeft) { diff --git a/Classes/ProgressViews/M13ProgressViewSegmentedBar.m b/Classes/ProgressViews/M13ProgressViewSegmentedBar.m index 13c8835..a8f7cf7 100644 --- a/Classes/ProgressViews/M13ProgressViewSegmentedBar.m +++ b/Classes/ProgressViews/M13ProgressViewSegmentedBar.m @@ -353,6 +353,8 @@ } //Set the paths to the layer _progressLayer.path = pathRef; + + CGPathRelease(pathRef); } - (void)drawBackground @@ -420,6 +422,8 @@ } //Set the paths to the layer _backgroundLayer.path = pathRef; + + CGPathRelease(pathRef); } - (void)drawIndeterminate @@ -496,6 +500,10 @@ //Set the paths to the layer _progressLayer.path = progressPathRef; _backgroundLayer.path = backgroundPathRef; + + CGPathRelease(progressPathRef); + CGPathRelease(backgroundPathRef); + //increase the index by one for movement indeterminateIndex += 1; if (indeterminateIndex == numberOfSegmentsToBeColored + _numberOfSegments) { diff --git a/Classes/ProgressViews/M13ProgressViewSegmentedRing.m b/Classes/ProgressViews/M13ProgressViewSegmentedRing.m index 95c94ec..4cb21d1 100644 --- a/Classes/ProgressViews/M13ProgressViewSegmentedRing.m +++ b/Classes/ProgressViews/M13ProgressViewSegmentedRing.m @@ -533,6 +533,8 @@ //Set the path _backgroundLayer.path = pathRef; + + CGPathRelease(pathRef); } - (void)drawProgress @@ -572,6 +574,8 @@ //Set the path _progressLayer.path = pathRef; + CGPathRelease(pathRef); + //Update label _percentageLabel.text = [_percentageFormatter stringFromNumber:[NSNumber numberWithFloat:self.progress]]; }