Bug 914521 - Hold a stack reference to mScriptGlobal when dispatching sync events. r=bz
Note also MMAdeathGrip earlier in the function.
This commit is contained in:
@@ -9214,18 +9214,23 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
SetDocCurrentStateObj(mOSHE);
|
||||
|
||||
// Dispatch the popstate and hashchange events, as appropriate.
|
||||
if (mScriptGlobal) {
|
||||
//
|
||||
// The event dispatch below can cause us to re-enter script and
|
||||
// destroy the docshell, nulling out mScriptGlobal. Hold a stack
|
||||
// reference to avoid null derefs. See bug 914521.
|
||||
nsRefPtr<nsGlobalWindow> win = mScriptGlobal;
|
||||
if (win) {
|
||||
// Fire a hashchange event URIs differ, and only in their hashes.
|
||||
bool doHashchange = sameExceptHashes && !curHash.Equals(newHash);
|
||||
|
||||
if (historyNavBetweenSameDoc || doHashchange) {
|
||||
mScriptGlobal->DispatchSyncPopState();
|
||||
win->DispatchSyncPopState();
|
||||
}
|
||||
|
||||
if (doHashchange) {
|
||||
// Make sure to use oldURI here, not mCurrentURI, because by
|
||||
// now, mCurrentURI has changed!
|
||||
mScriptGlobal->DispatchAsyncHashchange(oldURI, aURI);
|
||||
win->DispatchAsyncHashchange(oldURI, aURI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user