Bug 1599569 - Make nsScriptSecurityManager::ClearJSCallbacks into a static method. r=kmag

XPConnect calls this method during shutdown after the pointer to the
singleton nsScriptSecurityManager has been cleared, so it is actually
calling it with a null |this|. Nobody noticed this because it isn't
actually using |this|. This patch turns it into a static method to
make the sanitizers happy.

Differential Revision: https://phabricator.services.mozilla.com/D54846

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew McCreight 2019-11-27 20:57:43 +00:00
parent 32092a7398
commit 139398a824
3 changed files with 5 additions and 2 deletions

View File

@ -1389,6 +1389,7 @@ void nsScriptSecurityManager::InitJSCallbacks(JSContext* aCx) {
JS_SetTrustedPrincipals(aCx, BasePrincipal::Cast(mSystemPrincipal));
}
/* static */
void nsScriptSecurityManager::ClearJSCallbacks(JSContext* aCx) {
JS_SetSecurityCallbacks(aCx, nullptr);
JS_SetTrustedPrincipals(aCx, nullptr);

View File

@ -52,7 +52,9 @@ class nsScriptSecurityManager final : public nsIScriptSecurityManager {
static void InitStatics();
void InitJSCallbacks(JSContext* aCx);
void ClearJSCallbacks(JSContext* aCx);
// This has to be static because it is called after gScriptSecMan is cleared.
static void ClearJSCallbacks(JSContext* aCx);
static already_AddRefed<mozilla::SystemPrincipal>
SystemPrincipalSingletonConstructor();

View File

@ -1121,7 +1121,7 @@ void XPCJSRuntime::Shutdown(JSContext* cx) {
JS::SetGCSliceCallback(cx, mPrevGCSliceCallback);
nsScriptSecurityManager::GetScriptSecurityManager()->ClearJSCallbacks(cx);
nsScriptSecurityManager::ClearJSCallbacks(cx);
// Shut down the helper threads
gHelperThreads->Shutdown();