adium 5425:ad16b17fcde5: Fix a couple of leaks found by the stat...

commits at adium.im commits at adium.im
Wed Apr 17 16:14:08 UTC 2013


details:	http://hg.adium.im/adium/rev/ad16b17fcde5
revision:	5425:ad16b17fcde5
branch:		adium-1.6
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Wed Apr 17 18:12:11 2013 +0200

Fix a couple of leaks found by the static analyzer.

The content fitlering arrays in practice should never get released as long as Adium is running, but lets release them for good measure

diffs (95 lines):

diff -r 9e31c6d752d7 -r ad16b17fcde5 Plugins/Purple Service/AIPurpleCertificateViewer.h
--- a/Plugins/Purple Service/AIPurpleCertificateViewer.h	Wed Apr 17 17:20:25 2013 +0200
+++ b/Plugins/Purple Service/AIPurpleCertificateViewer.h	Wed Apr 17 18:12:11 2013 +0200
@@ -14,10 +14,11 @@
  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
+#import <Adium/AIWindowController.h>
 
 @class AIAccount;
 
- at interface AIPurpleCertificateViewer : NSObject {
+ at interface AIPurpleCertificateViewer : AIWindowController {
 	CFArrayRef certificatechain;
 	
 	AIAccount *account;
diff -r 9e31c6d752d7 -r ad16b17fcde5 Plugins/Purple Service/AIPurpleCertificateViewer.m
--- a/Plugins/Purple Service/AIPurpleCertificateViewer.m	Wed Apr 17 17:20:25 2013 +0200
+++ b/Plugins/Purple Service/AIPurpleCertificateViewer.m	Wed Apr 17 18:12:11 2013 +0200
@@ -21,7 +21,7 @@
 @interface AIPurpleCertificateViewer (privateMethods)
 
 - (id)initWithCertificateChain:(CFArrayRef)cc forAccount:(AIAccount*)_account;
-- (IBAction)showWindow:(id)sender;
+- (void)showOnWindow:(NSWindow *)parentWindow __attribute__((ns_consumes_self));
 - (void)certificateSheetDidEnd:(SFCertificatePanel*)panel returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
 
 @end
@@ -31,7 +31,6 @@
 + (void)displayCertificateChain:(CFArrayRef)cc forAccount:(AIAccount*)account {
 	AIPurpleCertificateViewer *viewer = [[self alloc] initWithCertificateChain:cc forAccount:account];
 	[viewer showWindow:nil];
-	[viewer release];
 }
 
 - (id)initWithCertificateChain:(CFArrayRef)cc forAccount:(AIAccount*)_account {
@@ -40,7 +39,7 @@
 		CFRetain(certificatechain);
 		account = _account;
 	}
-	return [self retain];
+	return self;
 }
 
 - (void)dealloc {
@@ -54,13 +53,23 @@
 
 - (void)editAccountWindow:(NSWindow*)window didOpenForAccount:(AIAccount *)inAccount {
 	SFCertificatePanel *panel = [[SFCertificatePanel alloc] init];
-	[panel beginSheetForWindow:window modalDelegate:self didEndSelector:@selector(certificateSheetDidEnd:returnCode:contextInfo:) contextInfo:window certificates:(NSArray*)certificatechain showGroup:YES];
+	
+	[panel beginSheetForWindow:window
+				 modalDelegate:self
+				didEndSelector:@selector(certificateSheetDidEnd:returnCode:contextInfo:)
+				   contextInfo:window
+				  certificates:(NSArray*)certificatechain
+					 showGroup:YES];
 }
 
 - (void)certificateSheetDidEnd:(SFCertificatePanel*)panel returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
 	NSWindow *win = (NSWindow*)contextInfo;
+	
 	[panel release];
+	
 	[win performSelector:@selector(performClose:) withObject:nil afterDelay:0.0];
+	
+	[self autorelease];
 }
 
 @end
diff -r 9e31c6d752d7 -r ad16b17fcde5 Source/AdiumContentFiltering.m
--- a/Source/AdiumContentFiltering.m	Wed Apr 17 17:20:25 2013 +0200
+++ b/Source/AdiumContentFiltering.m	Wed Apr 17 18:12:11 2013 +0200
@@ -37,9 +37,20 @@
 }
 
 - (void)dealloc
-{	
+{
 	[stringsRequiringPolling release];
 	[delayedFilteringDict release];
+	
+	NSInteger i,j;
+	
+	for (j = 0; j < FILTER_DIRECTION_COUNT; j++) {
+		for (i = 0; i < FILTER_TYPE_COUNT; i ++) {
+			[contentFilter[i][j] release];
+			[delayedContentFilters[i][j] release];
+		}
+		
+		[htmlContentFilters[j] release];
+	}
 
 	[super dealloc];
 }




More information about the commits mailing list