Title: [252729] trunk/Source/WebCore
Revision
252729
Author
[email protected]
Date
2019-11-20 23:25:43 -0800 (Wed, 20 Nov 2019)

Log Message

Crash at com.apple.WebCore: -[WebRevealHighlight revealContext:drawRectsForItem:]
https://bugs.webkit.org/show_bug.cgi?id=204434

Reviewed by Megan Gardner.

_attributedString was not retained, leading to a potential use-after-dealloc. Fix
this by wrapping it in a RetainPtr. While we're here, remove explicit ivars and
property synthesis and copy the string during assignment.

Reveal functionality is currently not testable.

* editing/cocoa/DictionaryLookup.mm:
(SOFT_LINK_CLASS_OPTIONAL):
(-[WebRevealHighlight initWithHighlightRect:useDefaultHighlight:attributedString:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252728 => 252729)


--- trunk/Source/WebCore/ChangeLog	2019-11-21 06:02:50 UTC (rev 252728)
+++ trunk/Source/WebCore/ChangeLog	2019-11-21 07:25:43 UTC (rev 252729)
@@ -1,3 +1,20 @@
+2019-11-20  Conrad Shultz  <[email protected]>
+
+        Crash at com.apple.WebCore: -[WebRevealHighlight revealContext:drawRectsForItem:]
+        https://bugs.webkit.org/show_bug.cgi?id=204434
+
+        Reviewed by Megan Gardner.
+
+        _attributedString was not retained, leading to a potential use-after-dealloc. Fix
+        this by wrapping it in a RetainPtr. While we're here, remove explicit ivars and
+        property synthesis and copy the string during assignment.
+
+        Reveal functionality is currently not testable.
+
+        * editing/cocoa/DictionaryLookup.mm:
+        (SOFT_LINK_CLASS_OPTIONAL):
+        (-[WebRevealHighlight initWithHighlightRect:useDefaultHighlight:attributedString:]):
+
 2019-11-20  Fujii Hironori  <[email protected]>
 
         [MSVC] error C2039: 'weakPtrFactory': is not a member of 'WebCore::DocumentStorageAccess::requestStorageAccess::<lambda_3f2cfd7704f93d8fe19d5b5f064f8add>'

Modified: trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm (252728 => 252729)


--- trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm	2019-11-21 06:02:50 UTC (rev 252728)
+++ trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm	2019-11-21 07:25:43 UTC (rev 252729)
@@ -79,14 +79,11 @@
 @interface WebRevealHighlight <RVPresenterHighlightDelegate> : NSObject {
 @private
     Function<void()> _clearTextIndicator;
-    NSRect _highlightRect;
-    BOOL _useDefaultHighlight;
-    NSAttributedString *_attributedString;
 }
 
 @property (nonatomic, readonly) NSRect highlightRect;
 @property (nonatomic, readonly) BOOL useDefaultHighlight;
-@property (nonatomic, readonly) NSAttributedString *attributedString;
+@property (nonatomic, readonly) RetainPtr<NSAttributedString> attributedString;
 
 - (instancetype)initWithHighlightRect:(NSRect)highlightRect useDefaultHighlight:(BOOL)useDefaultHighlight attributedString:(NSAttributedString *) attributedString;
 - (void)setClearTextIndicator:(Function<void()>&&)clearTextIndicator;
@@ -95,10 +92,6 @@
 
 @implementation WebRevealHighlight
 
-@synthesize highlightRect=_highlightRect;
-@synthesize useDefaultHighlight=_useDefaultHighlight;
-@synthesize attributedString=_attributedString;
-
 - (instancetype)initWithHighlightRect:(NSRect)highlightRect useDefaultHighlight:(BOOL)useDefaultHighlight attributedString:(NSAttributedString *) attributedString
 {
     if (!(self = [super init]))
@@ -106,7 +99,7 @@
     
     _highlightRect = highlightRect;
     _useDefaultHighlight = useDefaultHighlight;
-    _attributedString = attributedString;
+    _attributedString = adoptNS([attributedString copy]);
     
     return self;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to