Fix for crash in AppKit accessibility.
authorandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jan 2020 22:17:49 +0000 (22:17 +0000)
committerandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jan 2020 22:17:49 +0000 (22:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=206902

Reviewed by Chris Fleizach.

Accessibility methods invoked in the secondary thread that Return id
values retrieved from the main thread, need to retain/autoRelease the returned ids.

* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
(-[WKAccessibilityWebPageObject ALLOW_DEPRECATED_IMPLEMENTATIONS_END]):
(-[WKAccessibilityWebPageObject accessibilityAttributeSizeValue]):
(-[WKAccessibilityWebPageObject accessibilityAttributePositionValue]):
(-[WKAccessibilityWebPageObject accessibilityDataDetectorValue:point:]):

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

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm

index 7eb9e8c..d5c83f9 100644 (file)
@@ -1,3 +1,19 @@
+2020-01-28  Andres Gonzalez  <andresg_22@apple.com>
+
+        Fix for crash in AppKit accessibility.
+        https://bugs.webkit.org/show_bug.cgi?id=206902
+
+        Reviewed by Chris Fleizach.
+
+        Accessibility methods invoked in the secondary thread that Return id
+        values retrieved from the main thread, need to retain/autoRelease the returned ids.
+
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
+        (-[WKAccessibilityWebPageObject ALLOW_DEPRECATED_IMPLEMENTATIONS_END]):
+        (-[WKAccessibilityWebPageObject accessibilityAttributeSizeValue]):
+        (-[WKAccessibilityWebPageObject accessibilityAttributePositionValue]):
+        (-[WKAccessibilityWebPageObject accessibilityDataDetectorValue:point:]):
+
 2020-01-28  Brent Fulgham  <bfulgham@apple.com>
 
         Unreviewed test fix after r255217
index 5914ec4..4ec3e45 100644 (file)
@@ -86,7 +86,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
 - (NSArray *)accessibilityParameterizedAttributeNames
 ALLOW_DEPRECATED_IMPLEMENTATIONS_END
 {
-    return ax::retrieveValueFromMainThread<id>([PROTECTED_SELF] () -> id {
+    return ax::retrieveValueFromMainThread<RetainPtr<id>>([PROTECTED_SELF] () -> RetainPtr<id> {
         NSMutableArray *names = [NSMutableArray array];
         if (!protectedSelf->m_page)
             return names;
@@ -96,7 +96,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
                 [names addObject:(NSString *)name];
         }
         return names;
-    });
+    }).autorelease();
 }
 
 ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
@@ -182,25 +182,25 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
 
 - (NSValue *)accessibilityAttributeSizeValue
 {
-    return ax::retrieveValueFromMainThread<id>([PROTECTED_SELF] () -> id {
+    return ax::retrieveValueFromMainThread<RetainPtr<id>>([PROTECTED_SELF] () -> RetainPtr<id> {
         if (!protectedSelf->m_page)
             return nil;
         return [NSValue valueWithSize:(NSSize)protectedSelf->m_page->size()];
-    });
+    }).autorelease();
 }
 
 - (NSValue *)accessibilityAttributePositionValue
 {
-    return ax::retrieveValueFromMainThread<id>([PROTECTED_SELF] () -> id {
+    return ax::retrieveValueFromMainThread<RetainPtr<id>>([PROTECTED_SELF] () -> RetainPtr<id> {
         if (!protectedSelf->m_page)
             return nil;
         return [NSValue valueWithPoint:(NSPoint)protectedSelf->m_page->accessibilityPosition()];
-    });
+    }).autorelease();
 }
 
 - (id)accessibilityDataDetectorValue:(NSString *)attribute point:(WebCore::FloatPoint&)point
 {
-    return ax::retrieveValueFromMainThread<id>([&attribute, &point, PROTECTED_SELF] () -> id {
+    return ax::retrieveValueFromMainThread<RetainPtr<id>>([&attribute, &point, PROTECTED_SELF] () -> RetainPtr<id> {
         if (!protectedSelf->m_page)
             return nil;
         id value = nil;
@@ -215,7 +215,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
                 value = [NSString stringWithString:stringValue];
         }
         return value;
-    });
+    }).autorelease();
 }
 
 ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN