adium 4578:0016b375a750: Fixed 3 "Call to free data when error w...

commits at adium.im commits at adium.im
Sat Jan 28 22:27:07 UTC 2012


details:	http://hg.adium.im/adium/rev/0016b375a750
revision:	4578:0016b375a750
branch:		(none)
author:		Adrian Godoroja <robotive at me.com>
date:		Sun Jan 29 00:27:00 2012 +0200

Fixed 3 "Call to free data when error was returned during allocation" in AIKeychain. Analyzer Warnings--.

diffs (44 lines):

diff -r c0ad36313b1f -r 0016b375a750 Frameworks/AIUtilities Framework/Source/AIKeychain.m
--- a/Frameworks/AIUtilities Framework/Source/AIKeychain.m	Sat Jan 28 22:43:36 2012 +0200
+++ b/Frameworks/AIUtilities Framework/Source/AIKeychain.m	Sun Jan 29 00:27:00 2012 +0200
@@ -809,8 +809,11 @@
 	}
 
 	passwordString = [NSString stringWithBytes:passwordData length:passwordLength encoding:NSUTF8StringEncoding];
-	SecKeychainItemFreeContent(NULL, passwordData);
-
+	
+	if (err == noErr) {
+		SecKeychainItemFreeContent(NULL, passwordData);
+	}
+	
 	return passwordString;
 }
 
@@ -893,12 +896,12 @@
 					username, @"Username",
 					password, @"Password",
 					nil];
+				
+				SecKeychainItemFreeAttributesAndData(attrList, passwordBytes);
 			} else {
 				NSLog(@"Error extracting infomation from keychain item");
 			}
 
-			SecKeychainItemFreeAttributesAndData(attrList, passwordBytes);
-
 			if (item) {
 				CFRelease(item);
 			}
@@ -1221,7 +1224,10 @@
 	}
 
 	passwordString = [NSString stringWithBytes:passwordData length:passwordLength encoding:NSUTF8StringEncoding];
-	SecKeychainItemFreeContent(NULL, passwordData);
+
+	if (err == noErr) {
+		SecKeychainItemFreeContent(NULL, passwordData);
+	}
 
 	return passwordString;	
 }




More information about the commits mailing list