Bug Summary

File:Plugins/Purple Service/AIPurpleCertificateViewer.m
Location:line 49, column 2
Description:Memory Leak
Code is compiled without garbage collection.

Annotated Source Code

1//
2// AIPurpleCertificateViewer.m
3// Adium
4//
5// Created by Andreas Monitzer on 2007-11-04.
6// Copyright 2007 Andreas Monitzer. All rights reserved.
7//
8
9#import "AIPurpleCertificateViewer.h"
10#import <SecurityInterface/SFCertificatePanel.h>
11#import <AIUtilities/AITigerCompatibility.h>
12#import <Adium/AIAccountControllerProtocol.h>
13
14@interface AIPurpleCertificateViewer (privateMethods)
15
16- (id)initWithCertificateChain:(CFArrayRef)cc forAccount:(AIAccount*)_account;
17- (IBActionvoid)showWindow:(id)sender;
18
19@end
20
21@implementation AIPurpleCertificateViewer
22
23+ (void)displayCertificateChain:(CFArrayRef)cc forAccount:(AIAccount*)account {
24 AIPurpleCertificateViewer *viewer = [[self alloc] initWithCertificateChain:cc forAccount:account];
25 [viewer showWindow:nil0];
26 [viewer release];
27}
28
29- (id)initWithCertificateChain:(CFArrayRef)cc forAccount:(AIAccount*)_account {
30 if((self = [super init])) {
31 certificatechain = cc;
32 CFRetain(certificatechain);
33 account = _account;
34 }
35 return [self retain];
36}
37
38- (void)dealloc {
39 CFRelease(certificatechain);
40 [super dealloc];
41}
42
43- (IBActionvoid)showWindow:(id)sender {
44 [[adium accountController] editAccount:account onWindow:nil0 notifyingTarget:self];
45}
46
47- (void)editAccountWindow:(NSWindow*)window didOpenForAccount:(AIAccount *)inAccount {
[1] Method returns an object with a +1 retain count (owning reference).
48 SFCertificatePanel *panel = [[SFCertificatePanel alloc] init];
[2] Object allocated on line 48 and stored into 'panel' is no longer referenced after this point and has a retain count of +1 (object leaked).
49 [panel beginSheetForWindow:window modalDelegate:self didEndSelector:@selector(certificateSheetDidEnd:returnCode:contextInfo:) contextInfo:window certificates:(NSArray*)certificatechain showGroup:YES( BOOL ) 1];
50}
51
52- (void)certificateSheetDidEnd:(SFCertificatePanel*)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo {
53 NSWindow *win = (NSWindow*)contextInfo;
54 [panel release];
55 [win performSelector:@selector(performClose:) withObject:nil0 afterDelay:0.0];
56}
57
58@end