From 3c0a4410ad50ec2b4559edcf1b0926ad27c10728 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 9 Jun 2021 16:54:50 -0400 Subject: [PATCH] Fix crash if a frame is detached before the attach message arrives (see issue #2421) This reproduced on Mac with ResourceRequestHandlerTest.BasicStandardUnhandledModifyBeforeResourceLoad --- libcef/browser/frame_host_impl.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libcef/browser/frame_host_impl.cc b/libcef/browser/frame_host_impl.cc index dfad616ea..ab3c16d07 100644 --- a/libcef/browser/frame_host_impl.cc +++ b/libcef/browser/frame_host_impl.cc @@ -559,6 +559,12 @@ void CefFrameHostImpl::SendMessage(const std::string& name, void CefFrameHostImpl::FrameAttached() { CEF_REQUIRE_UIT(); + auto browser_info = GetBrowserInfo(); + if (!browser_info) { + // Already Detached. + return; + } + DCHECK(!is_attached_); if (!is_attached_) { is_attached_ = true; @@ -571,7 +577,7 @@ void CefFrameHostImpl::FrameAttached() { queued_actions_.pop(); } - GetBrowserInfo()->MaybeExecuteFrameNotification(base::BindOnce( + browser_info->MaybeExecuteFrameNotification(base::BindOnce( [](CefRefPtr self, CefRefPtr handler) { if (auto browser = self->GetBrowserHostBase()) {