Skip to content

Commit

Permalink
Fixing #502212: clang static analyzer identifies 2 leaks in Sparkle code
Browse files Browse the repository at this point in the history
  • Loading branch information
andymatuschak committed Jan 11, 2010
1 parent da3b5c2 commit 2e3ed79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 0 deletions SUAppcast.h
Expand Up @@ -17,6 +17,7 @@
NSString *userAgentString;
id delegate;
NSString *downloadFilename;
NSURLDownload *download;
}

- (void)fetchAppcastFromURL:(NSURL *)url;
Expand Down
17 changes: 6 additions & 11 deletions SUAppcast.m
Expand Up @@ -20,6 +20,7 @@ - (void)dealloc
{
[items release];
[userAgentString release];
[download release];
[super dealloc];
}

Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2e3ed79

Please sign in to comment.