Don't attempt to reuse the AIProxyListObject associated with a leaked ESObjectWithProperties; discard further use of it, clear its cache, and make a new one. Fixes #14294. Thanks to '''kbotc''' for the solution.
authorEvan Schoenberg
Mon, 29 Aug 2011 19:43:00 -0500
changeset 3632 1a4f7278fd3c
parent 3631 6faa02098034
child 3633 c4aaef3851de
Don't attempt to reuse the AIProxyListObject associated with a leaked ESObjectWithProperties; discard further use of it, clear its cache, and make a new one. Fixes #14294. Thanks to '''kbotc''' for the solution.
(transplanted from 7c3822c44c0f57c761f1e322c3641596d17a69d4)
Frameworks/Adium Framework/Source/AIProxyListObject.m
--- a/Frameworks/Adium Framework/Source/AIProxyListObject.m	Sun Aug 28 21:08:25 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIProxyListObject.m	Mon Aug 29 19:43:00 2011 -0500
@@ -49,15 +49,11 @@
 
 	if (proxy && proxy.listObject != inListObject) {
         /* This is generally a memory management failure; AIContactController stopped tracking a list object, but it never deallocated and
-		 * so never called [AIProxyListObject releaseProxyObject:].
-		 *
-		 * I've seen one case where proxy.listObject referred to a zombie object. I can't reproduce. If that happens, we'll get a crash here in
-		 * debug mode only.  -evands 8/28/11
+		 * so never called [AIProxyListObject releaseProxyObject:]. -evands 8/28/11
 		 */
-		AILogWithSignature(@"%@ was leaked! Meh.", proxy.listObject);
-
-		proxy.listObject = inListObject;
-		proxy.containingObject = inContainingObject;
+		AILogWithSignature(@"%@ was leaked! Meh. We'll recreate the proxy for %@.", proxy.listObject, proxy.key);
+		[self releaseProxyObject:proxy];
+		proxy = nil;
 	}
 
 	if (!proxy) {
@@ -74,6 +70,13 @@
 	return proxy;
 }
 
+- (void)flushCache
+{
+	self.cachedDisplayName = nil;
+	self.cachedDisplayNameString = nil;
+	self.cachedLabelAttributes = nil;
+}
+
 /*!
  * @brief Called when an AIListObject is done with an AIProxyListObject to remove it from the global dictionary
  *
@@ -81,19 +84,12 @@
  */
 + (void)releaseProxyObject:(AIProxyListObject *)proxyObject
 {
-	AILogWithSignature(@"%@", proxyObject);
 	[[proxyObject retain] autorelease];
 	proxyObject.listObject = nil;
+	[proxyObject flushCache];
 	[proxyDict removeObjectForKey:proxyObject.key];
 }
 
-- (void)flushCache
-{
-	self.cachedDisplayName = nil;
-	self.cachedDisplayNameString = nil;
-	self.cachedLabelAttributes = nil;
-}
-
 - (void)dealloc
 {
 	AILogWithSignature(@"%@", self);