Fix crash if a frame is detached before the attach message arrives (see issue #2421)

This reproduced on Mac with ResourceRequestHandlerTest.BasicStandardUnhandledModifyBeforeResourceLoad
This commit is contained in:
Marshall Greenblatt 2021-06-09 16:54:50 -04:00
parent ecbeca36e7
commit 3c0a4410ad
1 changed files with 7 additions and 1 deletions

View File

@ -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<CefFrameHostImpl> self,
CefRefPtr<CefFrameHandler> handler) {
if (auto browser = self->GetBrowserHostBase()) {