fixes bug 331040 "Crash when removing parent iframe in onbeforunload handler" patch by feng.qian, r=bryner, sr=bzbarsky, a=darin

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@194036 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
darin%meer.net
2006-04-10 20:05:21 +00:00
parent 554fd21698
commit 53f39c646d
2 changed files with 13 additions and 4 deletions

View File

@@ -4757,6 +4757,9 @@ nsDocShell::CreateAboutBlankContentViewer()
mCreatingDocument = PR_TRUE;
// mContentViewer->PermitUnload may release |this| docshell.
nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
if (mContentViewer) {
// We've got a content viewer already. Make sure the user
// permits us to discard the current document and replace it
@@ -6386,6 +6389,12 @@ nsDocShell::InternalLoad(nsIURI * aURI,
return NS_OK;
}
}
// mContentViewer->PermitUnload can destroy |this| docShell, which
// causes the next call of CanSavePresentation to crash.
// Hold onto |this| until we return, to prevent a crash from happening.
// (bug#331040)
nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
// Check if the page doesn't want to be unloaded. The javascript:
// protocol handler deals with this for javascript: URLs.