adium 4981:0d7a0d3f6855: This doesn't seem to need this pool, an...

commits at adium.im commits at adium.im
Thu Aug 9 01:11:05 UTC 2012


details:	http://hg.adium.im/adium/rev/0d7a0d3f6855
revision:	4981:0d7a0d3f6855
branch:		(none)
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Thu Aug 09 03:10:57 2012 +0200

This doesn't seem to need this pool, and it's cleaning up the error too early.

Fixes #16107

diffs (139 lines):

diff -r f9f4bea878af -r 0d7a0d3f6855 Frameworks/AIUtilities Framework/Source/AIKeychain.m
--- a/Frameworks/AIUtilities Framework/Source/AIKeychain.m	Wed Aug 08 22:40:31 2012 +0200
+++ b/Frameworks/AIUtilities Framework/Source/AIKeychain.m	Thu Aug 09 03:10:57 2012 +0200
@@ -666,64 +666,61 @@
 	NSParameterAssert(password != nil);
 	NSParameterAssert(server != nil);
 	// Domain is optional
-
-	@autoreleasepool {
+	
+	NSData   *passwordData = [password dataUsingEncoding:NSUTF8StringEncoding];
+	
+	NSData *serverData  = [server  dataUsingEncoding:NSUTF8StringEncoding];
+	NSData *domainData  = [domain  dataUsingEncoding:NSUTF8StringEncoding];
+	NSData *accountData = [account dataUsingEncoding:NSUTF8StringEncoding];
+	NSData *pathData    = [path    dataUsingEncoding:NSUTF8StringEncoding];
+	
+	NSAssert( (UINT_MAX >= [passwordData length]) &&
+			 (UINT_MAX >= [serverData length]) &&
+			 (UINT_MAX >= [domainData length]) &&
+			 (UINT_MAX >= [accountData length]) &&
+			 (UINT_MAX >= [pathData length]),
+			 @"Attempting to send more data than Keychain can handle.  Abort." );
+	// If keychainRef is NNULL, the password will be added to the default keychain
+	OSStatus err = SecKeychainAddInternetPassword(keychainRef,
+												  (UInt32)[serverData length],  [serverData bytes],
+												  // Domain is optional, so be sure to handle domain == nil
+												  domainData ? (UInt32)[domainData length] : 0,
+												  domainData ? [domainData bytes]  : NULL,
+												  // Account appears optional, even though it isn't so documented
+												  accountData ? (UInt32)[accountData length] : 0,
+												  accountData ? [accountData bytes]  : NULL,
+												  // Path appears optional, even though it isn't so documented
+												  pathData ? (UInt32)[pathData length] : 0,
+												  pathData ? [pathData bytes]  : NULL,
+												  port,
+												  protocol,
+												  authType,
+												  (UInt32)[passwordData length], [passwordData bytes],
+												  outKeychainItem);
+	
+	
+	if (outError) {
+		NSError *error = nil;
 		
-		NSData   *passwordData = [password dataUsingEncoding:NSUTF8StringEncoding];
-		
-		NSData *serverData  = [server  dataUsingEncoding:NSUTF8StringEncoding];
-		NSData *domainData  = [domain  dataUsingEncoding:NSUTF8StringEncoding];
-		NSData *accountData = [account dataUsingEncoding:NSUTF8StringEncoding];
-		NSData *pathData    = [path    dataUsingEncoding:NSUTF8StringEncoding];
-		
-		NSAssert( (UINT_MAX >= [passwordData length]) &&
-				 (UINT_MAX >= [serverData length]) &&
-				 (UINT_MAX >= [domainData length]) &&
-				 (UINT_MAX >= [accountData length]) &&
-				 (UINT_MAX >= [pathData length]),
-				 @"Attempting to send more data than Keychain can handle.  Abort." );
-		// If keychainRef is NNULL, the password will be added to the default keychain
-		OSStatus err = SecKeychainAddInternetPassword(keychainRef,
-													  (UInt32)[serverData length],  [serverData bytes],
-													  // Domain is optional, so be sure to handle domain == nil
-													  domainData ? (UInt32)[domainData length] : 0,
-													  domainData ? [domainData bytes]  : NULL,
-													  // Account appears optional, even though it isn't so documented
-													  accountData ? (UInt32)[accountData length] : 0,
-													  accountData ? [accountData bytes]  : NULL,
-													  // Path appears optional, even though it isn't so documented
-													  pathData ? (UInt32)[pathData length] : 0,
-													  pathData ? [pathData bytes]  : NULL,
-													  port,
-													  protocol,
-													  authType,
-													  (UInt32)[passwordData length], [passwordData bytes],
-													  outKeychainItem);
-		
-		
-		if (outError) {
-			NSError *error = nil;
-			
-			if (err != noErr) {
-				NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
-										  [NSValue valueWithPointer:SecKeychainAddInternetPassword], AIKEYCHAIN_ERROR_USERINFO_SECURITYFUNCTION,
-										  @"SecKeychainAddInternetPassword", AIKEYCHAIN_ERROR_USERINFO_SECURITYFUNCTIONNAME,
-										  AI_LOCALIZED_SECURITY_ERROR_DESCRIPTION(err), AIKEYCHAIN_ERROR_USERINFO_ERRORDESCRIPTION,
-										  server,  AIKEYCHAIN_ERROR_USERINFO_SERVER,
-										  domain,  AIKEYCHAIN_ERROR_USERINFO_DOMAIN,
-										  account, AIKEYCHAIN_ERROR_USERINFO_ACCOUNT,
-										  NSFileTypeForHFSTypeCode(protocol), AIKEYCHAIN_ERROR_USERINFO_PROTOCOL,
-										  NSFileTypeForHFSTypeCode(authType), AIKEYCHAIN_ERROR_USERINFO_AUTHENTICATIONTYPE,
-										  [NSValue valueWithPointer:keychainRef], AIKEYCHAIN_ERROR_USERINFO_KEYCHAIN,
-										  nil];
-				error = [NSError errorWithDomain:AIKEYCHAIN_ERROR_DOMAIN code:err userInfo:userInfo];
-			}
-			
-			*outError = error;
+		if (err != noErr) {
+			NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+									  [NSValue valueWithPointer:SecKeychainAddInternetPassword], AIKEYCHAIN_ERROR_USERINFO_SECURITYFUNCTION,
+									  @"SecKeychainAddInternetPassword", AIKEYCHAIN_ERROR_USERINFO_SECURITYFUNCTIONNAME,
+									  AI_LOCALIZED_SECURITY_ERROR_DESCRIPTION(err), AIKEYCHAIN_ERROR_USERINFO_ERRORDESCRIPTION,
+									  server,  AIKEYCHAIN_ERROR_USERINFO_SERVER,
+									  domain,  AIKEYCHAIN_ERROR_USERINFO_DOMAIN,
+									  account, AIKEYCHAIN_ERROR_USERINFO_ACCOUNT,
+									  NSFileTypeForHFSTypeCode(protocol), AIKEYCHAIN_ERROR_USERINFO_PROTOCOL,
+									  NSFileTypeForHFSTypeCode(authType), AIKEYCHAIN_ERROR_USERINFO_AUTHENTICATIONTYPE,
+									  [NSValue valueWithPointer:keychainRef], AIKEYCHAIN_ERROR_USERINFO_KEYCHAIN,
+									  nil];
+			error = [NSError errorWithDomain:AIKEYCHAIN_ERROR_DOMAIN code:err userInfo:userInfo];
 		}
 		
-		return (err == noErr);
+		*outError = error;
 	}
+	
+	return (err == noErr);
 }
 
 - (BOOL)addInternetPassword:(NSString *)password forServer:(NSString *)server account:(NSString *)account protocol:(SecProtocolType)protocol error:(out NSError **)outError
diff -r f9f4bea878af -r 0d7a0d3f6855 Frameworks/Adium Framework/Source/AIMetaContact.m
--- a/Frameworks/Adium Framework/Source/AIMetaContact.m	Wed Aug 08 22:40:31 2012 +0200
+++ b/Frameworks/Adium Framework/Source/AIMetaContact.m	Thu Aug 09 03:10:57 2012 +0200
@@ -683,12 +683,14 @@
 + (NSArray *)_forwardedProperties
 {
 	static NSArray *properties = nil;
+	static dispatch_once_t onceToken;
 	
-	if (properties == nil) {
+	dispatch_once(&onceToken, ^{
 		properties = [[NSArray alloc] initWithObjects:@"isOnline", @"isBlocked",
 					  @"isIdle", @"notAStranger", @"isMobile", @"signedOff", @"signedOn",
 					  @"alwaysOnline", @"unviewedContent", @"unviewedMention", nil];
-	}
+	});
+	
 	return properties;
 }
 




More information about the commits mailing list