diff options
author | Moonchild <moonchild@palemoon.org> | 2022-01-30 16:16:39 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-04-09 09:58:08 +0200 |
commit | 790cdb3dde52afa114ccd0a11658d7c5da1c208d (patch) | |
tree | e9619e85156ecfcbe40cb6f043f10dc635ca1644 | |
parent | 9c429abfb9fe38316901c44357648cb0f5512ebb (diff) | |
download | uxp-790cdb3dde52afa114ccd0a11658d7c5da1c208d.tar.gz |
Issue #1840 - Try to deal with bad website scripting loading/unloading modules.
Apparently Bing does rapid-fire loading/unloading of module scripts that
causes our attempts at resolving and initializing them to end up with
null fetched modules.
Returning null is probably a better way to handle this than crashing
on ms->ModuleRecord() ;-)
-rw-r--r-- | dom/script/ScriptLoader.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 5b7bea8d22..0fdde1f9d6 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -812,6 +812,10 @@ HostResolveImportedModule(JSContext* aCx, JS::Handle<JSObject*> aModule, if (!string.init(aCx, aSpecifier)) { return nullptr; } + if (!aModule || !aCx) { + // Our module context was ripped out from under us... + return nullptr; + } nsCOMPtr<nsIURI> uri = ResolveModuleSpecifier(script, string); @@ -824,6 +828,10 @@ HostResolveImportedModule(JSContext* aCx, JS::Handle<JSObject*> aModule, ModuleScript* ms = script->Loader()->GetFetchedModule(uri); MOZ_ASSERT(ms, "Resolved module not found in module map"); + if (!ms) { + // Already-resolved module has been removed from the map/unloaded... + return nullptr; + } MOZ_ASSERT(!ms->HasParseError()); MOZ_ASSERT(ms->ModuleRecord()); |