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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2335753002: Avoid use-after-free if frame is deleted when stopping loading. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 4491 matching lines...) Expand 10 before | Expand all | Expand 10 after
4502 observers_.AddObserver(observer); 4502 observers_.AddObserver(observer);
4503 } 4503 }
4504 4504
4505 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) { 4505 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) {
4506 observer->RenderFrameGone(); 4506 observer->RenderFrameGone();
4507 observers_.RemoveObserver(observer); 4507 observers_.RemoveObserver(observer);
4508 } 4508 }
4509 4509
4510 void RenderFrameImpl::OnStop() { 4510 void RenderFrameImpl::OnStop() {
4511 DCHECK(frame_); 4511 DCHECK(frame_);
4512
4513 // The stopLoading call may run script, which may cause this frame to be
4514 // detached/deleted. If that happens, return immediately.
4515 base::WeakPtr<RenderFrameImpl> weak_this = weak_factory_.GetWeakPtr();
4512 frame_->stopLoading(); 4516 frame_->stopLoading();
4513 if (!frame_->parent()) 4517 if (!weak_this)
4518 return;
4519
4520 if (frame_ && !frame_->parent())
4514 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, OnStop()); 4521 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, OnStop());
4515 4522
4516 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); 4523 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop());
4517 } 4524 }
4518 4525
4519 void RenderFrameImpl::WasHidden() { 4526 void RenderFrameImpl::WasHidden() {
4520 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); 4527 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden());
4521 4528
4522 #if defined(ENABLE_PLUGINS) 4529 #if defined(ENABLE_PLUGINS)
4523 for (auto* plugin : active_pepper_instances_) 4530 for (auto* plugin : active_pepper_instances_)
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
6322 // event target. Potentially a Pepper plugin will receive the event. 6329 // event target. Potentially a Pepper plugin will receive the event.
6323 // In order to tell whether a plugin gets the last mouse event and which it 6330 // In order to tell whether a plugin gets the last mouse event and which it
6324 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6331 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6325 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6332 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6326 // |pepper_last_mouse_event_target_|. 6333 // |pepper_last_mouse_event_target_|.
6327 pepper_last_mouse_event_target_ = nullptr; 6334 pepper_last_mouse_event_target_ = nullptr;
6328 #endif 6335 #endif
6329 } 6336 }
6330 6337
6331 } // namespace content 6338 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698