Commit e1c5c844 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Avoid use-after-free

SetNotWaitingForResponse can trigger a message pump which can then free
the object which |this| points to. This use-after-free can be avoided by
not dereferencing |this| after the call, by ensuring that calling
SetNotWaitingForResponse is the last thing done.

Bug: 1125199
Change-Id: Ie1289c93112151978e6daaa1d24326770028c529
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2407065Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806839}
parent d3452e93
...@@ -4235,10 +4235,13 @@ void WebContentsImpl::SetNotWaitingForResponse() { ...@@ -4235,10 +4235,13 @@ void WebContentsImpl::SetNotWaitingForResponse() {
return; return;
waiting_for_response_ = false; waiting_for_response_ = false;
if (delegate_)
delegate_->LoadingStateChanged(this, is_load_to_different_document_);
observers_.ForEachObserver( observers_.ForEachObserver(
[&](WebContentsObserver* observer) { observer->DidReceiveResponse(); }); [&](WebContentsObserver* observer) { observer->DidReceiveResponse(); });
// LoadingStateChanged must be called last in case it triggers deletion of
// |this| due to recursive message pumps.
if (delegate_)
delegate_->LoadingStateChanged(this, is_load_to_different_document_);
} }
void WebContentsImpl::SendScreenRects() { void WebContentsImpl::SendScreenRects() {
...@@ -5309,6 +5312,8 @@ void WebContentsImpl::ReadyToCommitNavigation( ...@@ -5309,6 +5312,8 @@ void WebContentsImpl::ReadyToCommitNavigation(
: false); : false);
} }
// LoadingStateChanged must be called last in case it triggers deletion of
// |this| due to recursive message pumps.
SetNotWaitingForResponse(); SetNotWaitingForResponse();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment