From 3adfdcfdeabddc25d8234cbea4e5cd05b72d0a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Tue, 1 Jan 2013 10:17:15 +0100 Subject: Fix Objective-C memory leaks. Change-Id: I62206d3813e8873f027ff46e525a30bcb2e945c9 diff --git a/Slimber/Cocoa/CocoaMenulet.mm b/Slimber/Cocoa/CocoaMenulet.mm index de9e9e9..c739fb4 100644 --- a/Slimber/Cocoa/CocoaMenulet.mm +++ b/Slimber/Cocoa/CocoaMenulet.mm @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2012-2013 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + #include "Slimber/Cocoa/CocoaMenulet.h" #pragma GCC diagnostic ignored "-Wold-style-cast" @@ -45,7 +51,7 @@ void CocoaMenulet::addItem(const std::string& name, const std::string& icon) { NSString* path = [[NSBundle mainBundle] pathForResource: [NSString stringWithUTF8String: icon.c_str()] ofType:@"png"]; NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; - [item setImage: [[NSImage alloc] initWithContentsOfFile: path]]; + [item setImage: image]; [image release]; } [menu addItem: item]; diff --git a/SwifTools/Cocoa/CocoaAction.mm b/SwifTools/Cocoa/CocoaAction.mm index d560787..d315caf 100644 --- a/SwifTools/Cocoa/CocoaAction.mm +++ b/SwifTools/Cocoa/CocoaAction.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -9,7 +9,7 @@ @implementation CocoaAction - (id) initWithFunction: (boost::function*) f { - if ([super init]) { + if ((self = [super init])) { function = f; } return self; diff --git a/SwifTools/URIHandler/MacOSXURIHandler.mm b/SwifTools/URIHandler/MacOSXURIHandler.mm index 0575d47..d386c86 100644 --- a/SwifTools/URIHandler/MacOSXURIHandler.mm +++ b/SwifTools/URIHandler/MacOSXURIHandler.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Remko Tronçon + * Copyright (c) 2011-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -20,7 +20,7 @@ using namespace Swift; @end @implementation MacOSXURIEventHandler - (id) initWithHandler: (URIHandler*) h { - if ([super init]) { + if ((self = [super init])) { handler = h; } return self; diff --git a/Swiften/Network/MacOSXProxyProvider.cpp b/Swiften/Network/MacOSXProxyProvider.cpp index f5925c3..a07c258 100644 --- a/Swiften/Network/MacOSXProxyProvider.cpp +++ b/Swiften/Network/MacOSXProxyProvider.cpp @@ -4,6 +4,12 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2013 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + #include #include @@ -30,6 +36,7 @@ static HostAddressPort getFromDictionary(CFDictionaryRef dict, CFStringRef enabl CFNumberRef zero = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &i); CFComparisonResult result = CFNumberCompare(numberValue, zero, NULL); CFRelease(numberValue); + CFRelease(zero); if(result != kCFCompareEqualTo) { int port = 0; @@ -92,6 +99,7 @@ HostAddressPort MacOSXProxyProvider::getSOCKS5Proxy() const { if(proxies != NULL) { result = getFromDictionary(proxies, kSCPropNetProxiesSOCKSEnable, kSCPropNetProxiesSOCKSProxy, kSCPropNetProxiesSOCKSPort); } + CFRelease(proxies); #endif return result; } -- cgit v0.10.2-6-g49f6