Title: [237055] trunk
Revision
237055
Author
[email protected]
Date
2018-10-11 16:48:19 -0700 (Thu, 11 Oct 2018)

Log Message

Clicking on bookmarklet crashes at NavigationState::willRecordNavigationSnapshot
https://bugs.webkit.org/show_bug.cgi?id=190476
<rdar://problem/32757191>

Reviewed by Megan Gardner.

Source/WebKit:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _saveBackForwardSnapshotForItem:]):
The WKBackForwardListItem can be nil. Then we retrieve a reference from it.
An Objective-C method that returns a reference is a great way to get
a null reference. Other code then assumes it's not null and crashes.
Add a nil check.

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/SnapshotStore.mm:
(TEST):
Add a test that we don't crash.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (237054 => 237055)


--- trunk/Source/WebKit/ChangeLog	2018-10-11 23:43:58 UTC (rev 237054)
+++ trunk/Source/WebKit/ChangeLog	2018-10-11 23:48:19 UTC (rev 237055)
@@ -1,5 +1,20 @@
 2018-10-11  Tim Horton  <[email protected]>
 
+        Clicking on bookmarklet crashes at NavigationState::willRecordNavigationSnapshot
+        https://bugs.webkit.org/show_bug.cgi?id=190476
+        <rdar://problem/32757191>
+
+        Reviewed by Megan Gardner.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _saveBackForwardSnapshotForItem:]):
+        The WKBackForwardListItem can be nil. Then we retrieve a reference from it.
+        An Objective-C method that returns a reference is a great way to get
+        a null reference. Other code then assumes it's not null and crashes.
+        Add a nil check.
+
+2018-10-11  Tim Horton  <[email protected]>
+
         Hardware keyboard arrow keys/spacebar don't scroll PDFs (works for web content)
         https://bugs.webkit.org/show_bug.cgi?id=190495
         <rdar://problem/22734616>

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


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-10-11 23:43:58 UTC (rev 237054)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-10-11 23:48:19 UTC (rev 237055)
@@ -4987,6 +4987,8 @@
 
 - (void)_saveBackForwardSnapshotForItem:(WKBackForwardListItem *)item
 {
+    if (!item)
+        return;
     _page->recordNavigationSnapshot(item._item);
 }
 

Modified: trunk/Tools/ChangeLog (237054 => 237055)


--- trunk/Tools/ChangeLog	2018-10-11 23:43:58 UTC (rev 237054)
+++ trunk/Tools/ChangeLog	2018-10-11 23:48:19 UTC (rev 237055)
@@ -1,5 +1,17 @@
 2018-10-11  Tim Horton  <[email protected]>
 
+        Clicking on bookmarklet crashes at NavigationState::willRecordNavigationSnapshot
+        https://bugs.webkit.org/show_bug.cgi?id=190476
+        <rdar://problem/32757191>
+
+        Reviewed by Megan Gardner.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/SnapshotStore.mm:
+        (TEST):
+        Add a test that we don't crash.
+
+2018-10-11  Tim Horton  <[email protected]>
+
         REGRESSION (r237037): Cannot use webkit-patch upload, always fails with unknown 'cc_radar'
 
         * Scripts/webkitpy/tool/steps/options.py:

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SnapshotStore.mm (237054 => 237055)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SnapshotStore.mm	2018-10-11 23:43:58 UTC (rev 237054)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/SnapshotStore.mm	2018-10-11 23:48:19 UTC (rev 237055)
@@ -205,4 +205,10 @@
     EXPECT_TRUE(imagesAreEqual(initialSnapshot.get(), snapshotAfterNavigation.get()));
 }
 
+TEST(SnapshotStore, SnapshottingNullBackForwardItemShouldNotCrash)
+{
+    RetainPtr<SnapshotTestWKWebView> webView = adoptNS([[SnapshotTestWKWebView alloc] init]);
+    [webView _saveBackForwardSnapshotForItem:nil];
+}
+
 #endif // WK_API_ENABLED && PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to