From 564676e77380d61a4fd6bddcf46d7d744940637b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 19 Jul 2020 13:06:58 +0200 Subject: [PATCH] Don't crash if wxWebView::EnableContextMenu() is called too early Although caller of wxWebViewEdgeImpl::GetSettings() check if it returns NULL and handle it gracefully, this function itself can crash if it's called too early, i.e. if ICoreWebView2 hasn't been created yet. Add a check to avoid this and just return NULL settings in this case. Closes #18840. --- src/msw/webview_edge.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/msw/webview_edge.cpp b/src/msw/webview_edge.cpp index 23fb94e03b..7538d4882c 100644 --- a/src/msw/webview_edge.cpp +++ b/src/msw/webview_edge.cpp @@ -325,6 +325,9 @@ HRESULT wxWebViewEdgeImpl::OnWebViewCreated(HRESULT result, ICoreWebView2Control ICoreWebView2Settings* wxWebViewEdgeImpl::GetSettings() { + if (!m_webView) + return NULL; + ICoreWebView2Settings* settings; HRESULT hr = m_webView->get_Settings(&settings); if (FAILED(hr))