Index: content/browser/renderer_host/render_view_host.cc |
=================================================================== |
--- content/browser/renderer_host/render_view_host.cc (revision 88283) |
+++ content/browser/renderer_host/render_view_host.cc (working copy) |
@@ -633,11 +633,15 @@ |
if (!content::SwappedOutMessages::CanHandleWhileSwappedOut(msg)) |
return true; |
- ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); |
- RenderViewHostObserver* observer; |
- while ((observer = it.GetNext()) != NULL) { |
- if (observer->OnMessageReceived(msg)) |
- return true; |
+ { |
+ // delegate_->OnMessageReceived can end up deleting |this|, in which case |
+ // the destructor for ObserverListBase::Iterator would access the deleted |
+ // observers_. |
+ ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); |
+ RenderViewHostObserver* observer; |
+ while ((observer = it.GetNext()) != NULL) |
+ if (observer->OnMessageReceived(msg)) |
+ return true; |
} |
if (delegate_->OnMessageReceived(msg)) |