diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-07-12 17:21:33 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-07-12 15:45:54 +0000 |
commit | cf4e820a3320ddb509dba7a40e58c5c2a76ab643 (patch) | |
tree | 5e21913b76d685a2821ebf1a1226c59b5fb795a8 | |
parent | 98b2687c3be88cf1ca1d0451e8d42af3ebcfdea1 (diff) | |
download | qtwebengine-chromium-cf4e820a3320ddb509dba7a40e58c5c2a76ab643.tar.gz |
Protect against nullptr dereference in GetSelectedText
Also remove the DCHECK in debug builds.
Should fix the crashes in
tst_QWebEngineView::inputContextQueryInput().
Note this is just a band-aid fix to prevent a crash, the underlying
issue is still there.
Change-Id: Ie416f3517896a0ad978540ae81d1401af4bfbacc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r-- | chromium/content/browser/renderer_host/render_widget_host_view_base.cc | 5 | ||||
-rw-r--r-- | chromium/content/browser/renderer_host/text_input_manager.cc | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/chromium/content/browser/renderer_host/render_widget_host_view_base.cc b/chromium/content/browser/renderer_host/render_widget_host_view_base.cc index c64958d9c59..3e7bec0cf0d 100644 --- a/chromium/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/chromium/content/browser/renderer_host/render_widget_host_view_base.cc @@ -307,7 +307,10 @@ RenderWidgetHostViewBase::CreateVideoCapturer() { base::string16 RenderWidgetHostViewBase::GetSelectedText() { if (!GetTextInputManager()) return base::string16(); - return GetTextInputManager()->GetTextSelection(this)->selected_text(); + auto text_selection = GetTextInputManager()->GetTextSelection(this); + if (text_selection) + return text_selection->selected_text(); + return base::string16(); } void RenderWidgetHostViewBase::SetBackgroundColor(SkColor color) { diff --git a/chromium/content/browser/renderer_host/text_input_manager.cc b/chromium/content/browser/renderer_host/text_input_manager.cc index 1f5d19f1d89..31bdc3cf5db 100644 --- a/chromium/content/browser/renderer_host/text_input_manager.cc +++ b/chromium/content/browser/renderer_host/text_input_manager.cc @@ -79,7 +79,9 @@ TextInputManager::GetCompositionRangeInfo() const { const TextInputManager::TextSelection* TextInputManager::GetTextSelection( RenderWidgetHostViewBase* view) const { +#ifndef TOOLKIT_QT DCHECK(!view || IsRegistered(view)); +#endif if (!view) view = active_view_; // A crash occurs when we end up here with an unregistered view. |