<http://webkit.org/b/59755> AXObjectCache::attachWrapper() over-retains an Accessibil...
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Apr 2011 23:54:35 +0000 (23:54 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Apr 2011 23:54:35 +0000 (23:54 +0000)
Reviewed by Chris Fleizach.

Previously, AXObjectCache::attachWrapper over-retained each
AccessibilityObjectWrapper it created, which is why
AXObjectCache::detachWrapper() contained an extra -release.

* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::AXObjectCache::detachWrapper): Removed extra -release.
(WebCore::AXObjectCache::attachWrapper): Because setWrapper()
assigns to a RetainPtr<> instance variable, it doesn't need a +1
retained object passed in.  Fix the leak by using a RetainPtr<>
for the AccessibilityObjectWrapper.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@85263 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/accessibility/mac/AXObjectCacheMac.mm

index 08f7cbb..7c0add0 100644 (file)
@@ -1,3 +1,20 @@
+2011-04-28  David Kilzer  <ddkilzer@apple.com>
+
+        <http://webkit.org/b/59755> AXObjectCache::attachWrapper() over-retains an AccessibilityObjectWrapper
+
+        Reviewed by Chris Fleizach.
+
+        Previously, AXObjectCache::attachWrapper over-retained each
+        AccessibilityObjectWrapper it created, which is why
+        AXObjectCache::detachWrapper() contained an extra -release.
+
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::AXObjectCache::detachWrapper): Removed extra -release.
+        (WebCore::AXObjectCache::attachWrapper): Because setWrapper()
+        assigns to a RetainPtr<> instance variable, it doesn't need a +1
+        retained object passed in.  Fix the leak by using a RetainPtr<>
+        for the AccessibilityObjectWrapper.
+
 2011-04-28  Nat Duca  <nduca@chromium.org>
 
         Reviewed by Darin Fisher.
index 4cd58e5..b2a89a0 100644 (file)
@@ -46,13 +46,13 @@ namespace WebCore {
 void AXObjectCache::detachWrapper(AccessibilityObject* obj)
 {
     [obj->wrapper() detach];
-    [obj->wrapper() release];
     obj->setWrapper(0);
 }
 
 void AXObjectCache::attachWrapper(AccessibilityObject* obj)
 {
-    obj->setWrapper([[AccessibilityObjectWrapper alloc] initWithAccessibilityObject:obj]);
+    RetainPtr<AccessibilityObjectWrapper> wrapper(AdoptNS, [[AccessibilityObjectWrapper alloc] initWithAccessibilityObject:obj]);
+    obj->setWrapper(wrapper.get());
 }
 
 void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotification notification)