[DOM] Clear sinks and block further use after storage observer shutdown.

This commit is contained in:
Moonchild 2022-02-09 18:23:27 +00:00 • committed by roytam1
commit bc2aa1f05c
2 changed files with 10 additions and 2 deletions

View file

@ -213,8 +213,10 @@ DOMStorageDBChild::RecvObserve(const nsCString& aTopic,
const nsString& aOriginAttributesPattern, const nsString& aOriginAttributesPattern,
const nsCString& aOriginScope) const nsCString& aOriginScope)
{ {
DOMStorageObserver::Self()->Notify( DOMStorageObserver* observer = DOMStorageObserver::Self();
aTopic.get(), aOriginAttributesPattern, aOriginScope); if (observer) {
observer->Notify(aTopic.get(), aOriginAttributesPattern, aOriginScope);
}
return true; return true;
} }

View file

@ -91,6 +91,8 @@ DOMStorageObserver::Shutdown()
return NS_ERROR_NOT_INITIALIZED; return NS_ERROR_NOT_INITIALIZED;
} }
sSelf->mSinks.Clear();
NS_RELEASE(sSelf); NS_RELEASE(sSelf);
return NS_OK; return NS_OK;
} }
@ -123,6 +125,10 @@ DOMStorageObserver::Observe(nsISupports* aSubject,
const char* aTopic, const char* aTopic,
const char16_t* aData) const char16_t* aData)
{ {
if (NS_WARN_IF(!sSelf)) { // Shutdown took place, so bail.
return NS_OK;
}
nsresult rv; nsresult rv;
// Start the thread that opens the database. // Start the thread that opens the database.