Permalink
Browse files

Fixing #502212: clang static analyzer identifies 2 leaks in Sparkle code

  • Loading branch information...
1 parent da3b5c2 commit 2e3ed79753329b66a395045e512677a1c8853b08 @andymatuschak andymatuschak committed Jan 11, 2010
Showing with 7 additions and 11 deletions.
  1. +1 −0 SUAppcast.h
  2. +6 −11 SUAppcast.m
View
@@ -17,6 +17,7 @@
NSString *userAgentString;
id delegate;
NSString *downloadFilename;
+ NSURLDownload *download;
}
- (void)fetchAppcastFromURL:(NSURL *)url;
View
@@ -20,6 +20,7 @@ - (void)dealloc
{
[items release];
[userAgentString release];
+ [download release];
[super dealloc];
}
@@ -34,11 +35,10 @@ - (void)fetchAppcastFromURL:(NSURL *)url
if (userAgentString)
[request setValue:userAgentString forHTTPHeaderField:@"User-Agent"];
- NSURLDownload *download = [[[NSURLDownload alloc] initWithRequest:request delegate:self] autorelease];
- CFRetain(download);
+ download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
-- (void)download:(NSURLDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename
+- (void)download:(NSURLDownload *)aDownload decideDestinationWithSuggestedFilename:(NSString *)filename
{
NSString* destinationFilename = NSTemporaryDirectory();
if (destinationFilename)
@@ -48,17 +48,14 @@ - (void)download:(NSURLDownload *)download decideDestinationWithSuggestedFilenam
}
}
-- (void)download:(NSURLDownload *)download didCreateDestination:(NSString *)path
+- (void)download:(NSURLDownload *)aDownload didCreateDestination:(NSString *)path
{
[downloadFilename release];
downloadFilename = [path copy];
}
-- (void)downloadDidFinish:(NSURLDownload *)download
-{
- if (download)
- CFRelease(download);
-
+- (void)downloadDidFinish:(NSURLDownload *)aDownload
+{
NSError *error = nil;
NSXMLDocument *document = [[[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:downloadFilename] options:0 error:&error] autorelease];
BOOL failed = NO;
@@ -181,8 +178,6 @@ - (void)downloadDidFinish:(NSURLDownload *)download
- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
{
- if (download)
- CFRelease(download);
if (downloadFilename)
{
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4

0 comments on commit 2e3ed79

Please sign in to comment.