Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3532)

Unified Diff: content/renderer/render_frame_impl.cc

Issue 1756483004: Fix use-after-free when navigating a subframe to about:blank. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes based on Daniel's review. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index ec975b5e8bd90cff456118229e8b216f512d2e6c..91482c17b7de7762f1547fd5992fc158bd976691 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -5501,9 +5501,18 @@ void RenderFrameImpl::NavigateInternal(
item_for_history_navigation, history_load_type,
is_client_redirect);
} else {
+ // The load of the URL can result in this frame being removed. Use a
+ // WeakPtr as an easy way to detect whether this has occured. If so, this
+ // method should return immediately and not touch any part of the object,
+ // otherwise it will result in a use-after-free bug.
+ base::WeakPtr<RenderFrameImpl> weak_this = weak_factory_.GetWeakPtr();
+
// Load the request.
frame_->load(request, load_type, item_for_history_navigation,
history_load_type, is_client_redirect);
+
+ if (!weak_this)
+ return;
}
} else {
// The browser expects the frame to be loading this navigation. Inform it

Powered by Google App Engine
This is Rietveld 408576698