Skip to content

Commit

Permalink
Merge r244970 - Null check m_mainFrame in WebPageProxy.cpp
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=197618
<rdar://problem/47463054>

Patch by Alex Christensen <achristensen@webkit.org> on 2019-05-06
Reviewed by Geoffrey Garen.

It's already null checked in some places, and the places where it isn't are causing crashes.
Let's fix all of them.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::decidePolicyForNewWindowAction):
(WebKit::WebPageProxy::createNewPage):
  • Loading branch information
Alex Christensen authored and mcatanzaro committed Aug 4, 2019
1 parent 06c0088 commit 9847134
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
16 changes: 16 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,19 @@
2019-05-06 Alex Christensen <achristensen@webkit.org>

Null check m_mainFrame in WebPageProxy.cpp
https://bugs.webkit.org/show_bug.cgi?id=197618
<rdar://problem/47463054>

Reviewed by Geoffrey Garen.

It's already null checked in some places, and the places where it isn't are causing crashes.
Let's fix all of them.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::decidePolicyForNewWindowAction):
(WebKit::WebPageProxy::createNewPage):

2019-05-14 Chris Dumez <cdumez@apple.com>

Crash under WebKit::WebProcessProxy::didBecomeUnresponsive()
Expand Down
9 changes: 6 additions & 3 deletions Source/WebKit/UIProcess/WebPageProxy.cpp
Expand Up @@ -4525,7 +4525,10 @@ void WebPageProxy::decidePolicyForNavigationAction(Ref<WebProcessProxy>&& proces
sourceFrameInfo = API::FrameInfo::create(originatingFrameInfoData, originatingPageID ? process->webPage(originatingPageID) : nullptr);

auto userInitiatedActivity = process->userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
bool shouldOpenAppLinks = !m_shouldSuppressAppLinksInNextNavigationPolicyDecision && destinationFrameInfo->isMainFrame() && !hostsAreEqual(URL({ }, m_mainFrame->url()), request.url()) && navigationActionData.navigationType != WebCore::NavigationType::BackForward;
bool shouldOpenAppLinks = !m_shouldSuppressAppLinksInNextNavigationPolicyDecision
&& destinationFrameInfo->isMainFrame()
&& (m_mainFrame ? !hostsAreEqual(m_mainFrame->url(), request.url()) : false)
&& navigationActionData.navigationType != WebCore::NavigationType::BackForward;

auto navigationAction = API::NavigationAction::create(WTFMove(navigationActionData), sourceFrameInfo.get(), destinationFrameInfo.ptr(), WTF::nullopt, WTFMove(request), originalRequest.url(), shouldOpenAppLinks, WTFMove(userInitiatedActivity), mainFrameNavigation);

Expand Down Expand Up @@ -4642,7 +4645,7 @@ void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, const Securi
sourceFrameInfo = API::FrameInfo::create(*frame, frameSecurityOrigin.securityOrigin());

auto userInitiatedActivity = m_process->userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
bool shouldOpenAppLinks = !hostsAreEqual(URL({ }, m_mainFrame->url()), request.url());
bool shouldOpenAppLinks = m_mainFrame ? !hostsAreEqual(m_mainFrame->url(), request.url()) : false;
auto navigationAction = API::NavigationAction::create(WTFMove(navigationActionData), sourceFrameInfo.get(), nullptr, frameName, WTFMove(request), URL { }, shouldOpenAppLinks, WTFMove(userInitiatedActivity));

m_navigationClient->decidePolicyForNavigationAction(*this, navigationAction.get(), WTFMove(listener), m_process->transformHandlesToObjects(userData.object()).get());
Expand Down Expand Up @@ -4813,7 +4816,7 @@ void WebPageProxy::createNewPage(const FrameInfoData& originatingFrameInfoData,
MESSAGE_CHECK(m_process, m_process->webFrame(originatingFrameInfoData.frameID));
auto originatingFrameInfo = API::FrameInfo::create(originatingFrameInfoData, m_process->webPage(originatingPageID));

auto mainFrameURL = m_mainFrame->url();
auto mainFrameURL = m_mainFrame ? m_mainFrame->url() : URL();

m_uiClient->createNewPage(*this, WTFMove(originatingFrameInfo), WTFMove(request), WTFMove(windowFeatures), WTFMove(navigationActionData), [this, protectedThis = makeRef(*this), mainFrameURL, request, reply = WTFMove(reply)] (RefPtr<WebPageProxy> newPage) mutable {
if (!newPage) {
Expand Down

0 comments on commit 9847134

Please sign in to comment.