mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 22:05:44 +00:00
Bug 394042 - "Dangling pointer in nsXULPDGlobalObject leads to mem corruption/crashes". r+sr=bzbarsky, a=jst.
This commit is contained in:
parent
a2a8e15eb0
commit
4c77c5f4dc
@ -105,6 +105,8 @@ protected:
|
||||
nsCOMPtr<nsIScriptContext> mScriptContexts[NS_STID_ARRAY_UBOUND];
|
||||
void * mScriptGlobals[NS_STID_ARRAY_UBOUND];
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mCachedPrincipal;
|
||||
|
||||
static JSClass gSharedGlobalClass;
|
||||
};
|
||||
|
||||
@ -759,6 +761,12 @@ nsXULPDGlobalObject::GetScriptGlobal(PRUint32 lang_id)
|
||||
void
|
||||
nsXULPDGlobalObject::ClearGlobalObjectOwner()
|
||||
{
|
||||
NS_ASSERTION(!mCachedPrincipal, "This shouldn't ever be set until now!");
|
||||
|
||||
// Cache mGlobalObjectOwner's principal if possible.
|
||||
if (this != nsXULPrototypeDocument::gSystemGlobal)
|
||||
mCachedPrincipal = mGlobalObjectOwner->DocumentPrincipal();
|
||||
|
||||
PRUint32 lang_ndx;
|
||||
NS_STID_FOR_INDEX(lang_ndx) {
|
||||
if (mScriptContexts[lang_ndx]) {
|
||||
@ -766,6 +774,7 @@ nsXULPDGlobalObject::ClearGlobalObjectOwner()
|
||||
mScriptContexts[lang_ndx] = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
mGlobalObjectOwner = nsnull;
|
||||
}
|
||||
|
||||
@ -806,9 +815,9 @@ nsXULPDGlobalObject::GetPrincipal()
|
||||
if (this == nsXULPrototypeDocument::gSystemGlobal) {
|
||||
return nsXULPrototypeDocument::gSystemPrincipal;
|
||||
}
|
||||
return nsnull;
|
||||
// Return the cached principal if it exists.
|
||||
return mCachedPrincipal;
|
||||
}
|
||||
|
||||
return mGlobalObjectOwner->DocumentPrincipal();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user