Title: [230884] trunk/Source
Revision
230884
Author
timo...@apple.com
Date
2018-04-20 23:16:29 -0700 (Fri, 20 Apr 2018)

Log Message

NULL dereference crash sometimes under [super initWithCoder:] in WebView

https://bugs.webkit.org/show_bug.cgi?id=184851
rdar://problem/39611236

Reviewed by Tim Horton.

Source/WebKit:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView effectiveAppearanceDidChange]):
Added a null check and call the code later in initialization.

Source/WebKitLegacy/mac:

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView effectiveAppearanceDidChange]):
Added a null check and call the code later in initialization.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (230883 => 230884)


--- trunk/Source/WebKit/ChangeLog	2018-04-21 06:16:01 UTC (rev 230883)
+++ trunk/Source/WebKit/ChangeLog	2018-04-21 06:16:29 UTC (rev 230884)
@@ -1,3 +1,17 @@
+2018-04-20  Timothy Hatcher  <timo...@apple.com>
+
+        NULL dereference crash sometimes under [super initWithCoder:] in WebView
+
+        https://bugs.webkit.org/show_bug.cgi?id=184851
+        rdar://problem/39611236
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]):
+        (-[WKWebView effectiveAppearanceDidChange]):
+        Added a null check and call the code later in initialization.
+
 2018-04-20  Tim Horton  <timothy_hor...@apple.com>
 
         Adjust geolocation feature flag

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (230883 => 230884)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-04-21 06:16:01 UTC (rev 230883)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-04-21 06:16:29 UTC (rev 230884)
@@ -696,6 +696,7 @@
 
     _impl->setAutomaticallyAdjustsContentInsets(true);
     _impl->setRequiresUserActionForEditingControlsManager([configuration _requiresUserActionForEditingControlsManager]);
+    _impl->setDefaultAppearance([self _defaultAppearance]);
 #endif
 
 #if ENABLE(ACCESSIBILITY_EVENTS)
@@ -6260,6 +6261,11 @@
 
 - (void)effectiveAppearanceDidChange
 {
+    // This can be called during [super initWithCoder:] and [super initWithFrame:].
+    // That is before _impl is ready to be used, so check. <rdar://problem/39611236>
+    if (!_impl)
+        return;
+
     _impl->setDefaultAppearance([self _defaultAppearance]);
 }
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (230883 => 230884)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-04-21 06:16:01 UTC (rev 230883)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-04-21 06:16:29 UTC (rev 230884)
@@ -1,3 +1,17 @@
+2018-04-20  Timothy Hatcher  <timo...@apple.com>
+
+        NULL dereference crash sometimes under [super initWithCoder:] in WebView
+
+        https://bugs.webkit.org/show_bug.cgi?id=184851
+        rdar://problem/39611236
+
+        Reviewed by Tim Horton.
+
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+        (-[WebView effectiveAppearanceDidChange]):
+        Added a null check and call the code later in initialization.
+
 2018-04-20  Tim Horton  <timothy_hor...@apple.com>
 
         Adjust geolocation feature flag

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (230883 => 230884)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-04-21 06:16:01 UTC (rev 230883)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-04-21 06:16:29 UTC (rev 230884)
@@ -1541,6 +1541,7 @@
 
 #if !PLATFORM(IOS)
     [self _registerDraggedTypes];
+    [self _updateDefaultAppearance];
 #endif
 
     [self _setIsVisible:[self _isViewVisible]];
@@ -5298,9 +5299,11 @@
 
 - (void)effectiveAppearanceDidChange
 {
-    if (!_private->page)
+    // This can be called during [super initWithCoder:] and [super initWithFrame:].
+    // That is before _private is ready to be used, so check. <rdar://problem/39611236>
+    if (!_private || !_private->page)
         return;
-    
+
     [self _updateDefaultAppearance];
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to