зеркало из https://github.com/mozilla/pjs.git
Fix leaks from nsDocument::mPrincipal by making it an nsCOMPtr. b=170201 r=mstoltz sr=jst
This commit is contained in:
Родитель
aed6c7a857
Коммит
965901161b
|
@ -529,7 +529,6 @@ nsDocument::nsDocument() : mSubDocuments(nsnull),
|
||||||
mHeaderData = nsnull;
|
mHeaderData = nsnull;
|
||||||
mChildNodes = nsnull;
|
mChildNodes = nsnull;
|
||||||
mModCount = 0;
|
mModCount = 0;
|
||||||
mPrincipal = nsnull;
|
|
||||||
mNextContentID = NS_CONTENT_ID_COUNTER_BASE;
|
mNextContentID = NS_CONTENT_ID_COUNTER_BASE;
|
||||||
mDTD = 0;
|
mDTD = 0;
|
||||||
mBoxObjectTable = nsnull;
|
mBoxObjectTable = nsnull;
|
||||||
|
@ -567,7 +566,7 @@ nsDocument::~nsDocument()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IF_RELEASE(mPrincipal);
|
mPrincipal = nsnull;
|
||||||
mDocumentLoadGroup = nsnull;
|
mDocumentLoadGroup = nsnull;
|
||||||
|
|
||||||
mParentDocument = nsnull;
|
mParentDocument = nsnull;
|
||||||
|
@ -752,7 +751,7 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
||||||
nsCOMPtr<nsISupports> owner;
|
nsCOMPtr<nsISupports> owner;
|
||||||
aChannel->GetOwner(getter_AddRefs(owner));
|
aChannel->GetOwner(getter_AddRefs(owner));
|
||||||
if (owner)
|
if (owner)
|
||||||
owner->QueryInterface(NS_GET_IID(nsIPrincipal), (void**)&mPrincipal);
|
mPrincipal = do_QueryInterface(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -766,7 +765,7 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup)
|
||||||
mDocumentTitle.Truncate();
|
mDocumentTitle.Truncate();
|
||||||
|
|
||||||
NS_IF_RELEASE(mDocumentURL);
|
NS_IF_RELEASE(mDocumentURL);
|
||||||
NS_IF_RELEASE(mPrincipal);
|
mPrincipal = nsnull;
|
||||||
mDocumentLoadGroup = nsnull;
|
mDocumentLoadGroup = nsnull;
|
||||||
|
|
||||||
// Delete references to sub-documents and kill the subdocument map,
|
// Delete references to sub-documents and kill the subdocument map,
|
||||||
|
@ -924,7 +923,7 @@ nsDocument::GetPrincipal(nsIPrincipal **aPrincipal)
|
||||||
return rv;
|
return rv;
|
||||||
NS_WARN_IF_FALSE(mDocumentURL, "no URL!");
|
NS_WARN_IF_FALSE(mDocumentURL, "no URL!");
|
||||||
if (NS_FAILED(rv = securityManager->GetCodebasePrincipal(mDocumentURL,
|
if (NS_FAILED(rv = securityManager->GetCodebasePrincipal(mDocumentURL,
|
||||||
&mPrincipal)))
|
getter_AddRefs(mPrincipal))))
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -615,7 +615,7 @@ protected:
|
||||||
nsString mDocumentTitle;
|
nsString mDocumentTitle;
|
||||||
nsIURI* mDocumentURL;
|
nsIURI* mDocumentURL;
|
||||||
nsCOMPtr<nsIURI> mDocumentBaseURL;
|
nsCOMPtr<nsIURI> mDocumentBaseURL;
|
||||||
nsIPrincipal* mPrincipal;
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||||
nsWeakPtr mDocumentLoadGroup;
|
nsWeakPtr mDocumentLoadGroup;
|
||||||
nsWeakPtr mDocumentContainer;
|
nsWeakPtr mDocumentContainer;
|
||||||
|
|
||||||
|
|
|
@ -2703,9 +2703,7 @@ nsHTMLDocument::ScriptWriteCommon(PRBool aNewlineTerminate)
|
||||||
mDocumentURL = subjectURI;
|
mDocumentURL = subjectURI;
|
||||||
NS_ADDREF(mDocumentURL);
|
NS_ADDREF(mDocumentURL);
|
||||||
|
|
||||||
NS_IF_RELEASE(mPrincipal);
|
|
||||||
mPrincipal = subject;
|
mPrincipal = subject;
|
||||||
NS_ADDREF(mPrincipal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,14 +394,13 @@ nsXMLDocument::Load(const nsAString& aUrl)
|
||||||
|
|
||||||
// Partial Reset, need to restore principal for security reasons and
|
// Partial Reset, need to restore principal for security reasons and
|
||||||
// event listener manager so that load listeners etc. will remain.
|
// event listener manager so that load listeners etc. will remain.
|
||||||
nsCOMPtr<nsIPrincipal> principal(dont_QueryInterface(mPrincipal));
|
nsCOMPtr<nsIPrincipal> principal = mPrincipal;
|
||||||
nsCOMPtr<nsIEventListenerManager> elm(dont_QueryInterface(mListenerManager));
|
nsCOMPtr<nsIEventListenerManager> elm = mListenerManager;
|
||||||
|
|
||||||
Reset(nsnull, nsnull);
|
Reset(nsnull, nsnull);
|
||||||
|
|
||||||
mPrincipal = principal;
|
mPrincipal = principal;
|
||||||
mListenerManager = elm;
|
mListenerManager = elm;
|
||||||
NS_IF_ADDREF(mPrincipal);
|
|
||||||
NS_IF_ADDREF(mListenerManager);
|
NS_IF_ADDREF(mListenerManager);
|
||||||
|
|
||||||
SetDocumentURL(uri);
|
SetDocumentURL(uri);
|
||||||
|
@ -433,15 +432,15 @@ nsXMLDocument::Load(const nsAString& aUrl)
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// Set a principal for this document
|
// Set a principal for this document
|
||||||
NS_IF_RELEASE(mPrincipal);
|
mPrincipal = nsnull;
|
||||||
nsCOMPtr<nsISupports> channelOwner;
|
nsCOMPtr<nsISupports> channelOwner;
|
||||||
rv = channel->GetOwner(getter_AddRefs(channelOwner));
|
rv = channel->GetOwner(getter_AddRefs(channelOwner));
|
||||||
if (NS_SUCCEEDED(rv) && channelOwner)
|
if (NS_SUCCEEDED(rv) && channelOwner)
|
||||||
rv = channelOwner->QueryInterface(NS_GET_IID(nsIPrincipal), (void**)&mPrincipal);
|
mPrincipal = do_QueryInterface(channelOwner, &rv);
|
||||||
|
|
||||||
if (NS_FAILED(rv) || !channelOwner)
|
if (NS_FAILED(rv) || !channelOwner)
|
||||||
{
|
{
|
||||||
rv = secMan->GetCodebasePrincipal(uri, &mPrincipal);
|
rv = secMan->GetCodebasePrincipal(uri, getter_AddRefs(mPrincipal));
|
||||||
if (!mPrincipal) return rv;
|
if (!mPrincipal) return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче