Bug 1744940 - Prevent leak when nsHttpHandler::NewProxiedChannel is called during shutdown r=necko-reviewers,kershaw

In 1738984 we added this early return when the method is called during
shutdown to prevent NSS from being initialized and to fail things
as early as possible.
However, this check belongs at the top of the method, not after the
allocation.

Differential Revision: https://phabricator.services.mozilla.com/D133335
This commit is contained in:
Valentin Gosu 2021-12-09 10:54:19 +00:00
Родитель 073ffe9321
Коммит b984c37dc7
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -2048,6 +2048,11 @@ NS_IMETHODIMP
nsHttpHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* givenProxyInfo,
uint32_t proxyResolveFlags, nsIURI* proxyURI,
nsILoadInfo* aLoadInfo, nsIChannel** result) {
// Avoid a late initialization
if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownNetTeardown)) {
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
}
HttpBaseChannel* httpChannel;
LOG(("nsHttpHandler::NewProxiedChannel [proxyInfo=%p]\n", givenProxyInfo));
@ -2060,11 +2065,6 @@ nsHttpHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* givenProxyInfo,
httpChannel = new nsHttpChannel();
}
// Avoid a late initialization
if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownNetTeardown)) {
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
}
return SetupChannelInternal(httpChannel, uri, givenProxyInfo,
proxyResolveFlags, proxyURI, aLoadInfo, result);
}