diff options
author | Viktor Engelmann <viktor.engelmann@qt.io> | 2017-04-06 15:19:24 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-04-15 14:14:30 +0000 |
commit | f88200c6b44a5e68f7d9fabde9ac58c86728acb4 (patch) | |
tree | 300703b03f64c1010a41ed837c213359038755f2 | |
parent | fa94cb09e095a6d6c5634ae8543fc70145594c05 (diff) |
Add two nullpointer checks
The two nullpointer checks prevent crashes that happened when one
clicked on a link with target="_blank" in 56-based.
Task-number: QTBUG-46713
Change-Id: I1f8a20a52726ab05a85dbca2ec49784985384d06
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 7 | ||||
-rw-r--r-- | src/core/web_contents_view_qt.cpp | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index b30c4dfa7..de6e29de6 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -447,8 +447,11 @@ content::MediaObserver *ContentBrowserClientQt::GetMediaObserver() void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, content::WebPreferences *web_prefs) { - if (content::WebContents *webContents = rvh->GetDelegate()->GetAsWebContents()) - static_cast<WebContentsDelegateQt*>(webContents->GetDelegate())->overrideWebPreferences(webContents, web_prefs); + if (content::WebContents *webContents = rvh->GetDelegate()->GetAsWebContents()) { + WebContentsDelegateQt* delegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate()); + if (delegate) + delegate->overrideWebPreferences(webContents, web_prefs); + } } content::QuotaPermissionContext *ContentBrowserClientQt::CreateQuotaPermissionContext() diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp index 4f921bd07..844544887 100644 --- a/src/core/web_contents_view_qt.cpp +++ b/src/core/web_contents_view_qt.cpp @@ -118,8 +118,10 @@ gfx::NativeView WebContentsViewQt::GetNativeView() const void WebContentsViewQt::GetContainerBounds(gfx::Rect* out) const { - const QRectF r(m_client->viewportRect()); - *out = gfx::Rect(r.x(), r.y(), r.width(), r.height()); + if (m_client) { + const QRectF r(m_client->viewportRect()); + *out = gfx::Rect(r.x(), r.y(), r.width(), r.height()); + } } void WebContentsViewQt::Focus() |