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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 1007123003: Clear RenderFrameImpl::frame_ pointer after deleting it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Verify OnMessageReceived returns false Created 5 years, 9 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 437e8c98be937398ffd4b3ca46cdfb4c5b964f16..7e9230558fcca26af5af51c99b1fd8baf76efe29 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -952,6 +952,11 @@ void RenderFrameImpl::DidHideExternalPopupMenu() {
#endif
bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
+ // We may get here while detaching, when the WebFrame has been deleted. Do
+ // not process any messages in this state.
+ if (!frame_)
+ return false;
+
// TODO(kenrb): document() should not be null, but as a transitional step
// we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing messages
// to this method. This happens for a top-level remote frame, where a
@@ -2104,8 +2109,11 @@ void RenderFrameImpl::frameDetached(blink::WebFrame* frame) {
if (is_subframe)
frame->parent()->removeChild(frame);
- // |frame| is invalid after here.
+ // |frame| is invalid after here. Be sure to clear frame_ as well, since this
+ // object may not be deleted immediately and other methods may try to access
+ // it.
frame->close();
+ frame_ = nullptr;
if (is_subframe) {
delete this;
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698