summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/tab_contents
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-28 22:00:21 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-28 22:00:21 +0000
commit2791b2cefe7fadfab1b15340c5788d284d13a5bb (patch)
tree862642510696eb931bc7b12e040c8bd631e36573 /chrome/browser/ui/tab_contents
parent708f3b3ad64ea2f445ac975d9301db9304214d54 (diff)
downloadchromium_src-2791b2cefe7fadfab1b15340c5788d284d13a5bb.zip
chromium_src-2791b2cefe7fadfab1b15340c5788d284d13a5bb.tar.gz
chromium_src-2791b2cefe7fadfab1b15340c5788d284d13a5bb.tar.bz2
Fix memory corruption by calling clear_owner() earlier. The Notify() calls can result in the InfoBarDelegate being deleted, so it's wrong to call clear_owner() after them; call before them instead.
BUG=89915 TEST=none TBR=erg Review URL: http://codereview.chromium.org/7531008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/tab_contents')
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_wrapper.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
index 6d4d418..14c8c21 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
@@ -529,6 +529,7 @@ void TabContentsWrapper::ReplaceInfoBar(InfoBarDelegate* old_delegate,
infobars_.insert(infobars_.begin() + i, new_delegate);
+ old_delegate->clear_owner();
InfoBarReplacedDetails replaced_details(old_delegate, new_delegate);
NotificationService::current()->Notify(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED,
@@ -536,7 +537,6 @@ void TabContentsWrapper::ReplaceInfoBar(InfoBarDelegate* old_delegate,
Details<InfoBarReplacedDetails>(&replaced_details));
infobars_.erase(infobars_.begin() + i + 1);
- old_delegate->clear_owner();
}
InfoBarDelegate* TabContentsWrapper::GetInfoBarDelegateAt(size_t index) {
@@ -680,6 +680,7 @@ void TabContentsWrapper::RemoveInfoBarInternal(InfoBarDelegate* delegate,
DCHECK_LT(i, infobars_.size());
InfoBarDelegate* infobar = infobars_[i];
+ infobar->clear_owner();
InfoBarRemovedDetails removed_details(infobar, animate);
NotificationService::current()->Notify(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
@@ -687,7 +688,6 @@ void TabContentsWrapper::RemoveInfoBarInternal(InfoBarDelegate* delegate,
Details<InfoBarRemovedDetails>(&removed_details));
infobars_.erase(infobars_.begin() + i);
- delegate->clear_owner();
// Remove ourselves as an observer if we are tracking no more InfoBars.
if (infobars_.empty()) {
registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,