diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-06-27 02:09:19 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-06-27 02:09:19 +0200 |
commit | ffacca4e18db3e287d4a5f492c316b65b8def05a (patch) | |
tree | c66c62b4195c335e3827bb24a0dbfc2d01b4249e /dom/base | |
parent | ff43879b8d83128e3a3c5350bb5ce2bb776ab92d (diff) | |
download | uxp-ffacca4e18db3e287d4a5f492c316b65b8def05a.tar.gz |
Issue mcp-graveyard/UXP#1602 - Make sure we have a JSObject before trying to get global.
Dynamic script loading/unloading (thank you modules) can yank the script
out from under us before the JS API for it is initialized, leading to
null deref crashes.
This adds a simple check if the passed-in object is sane and present.
Resolves #1602
Diffstat (limited to 'dom/base')
-rw-r--r-- | dom/base/ScriptSettings.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/dom/base/ScriptSettings.cpp b/dom/base/ScriptSettings.cpp index d67f2167ae..92ab221c95 100644 --- a/dom/base/ScriptSettings.cpp +++ b/dom/base/ScriptSettings.cpp @@ -485,7 +485,13 @@ AutoJSAPI::Init(nsIGlobalObject* aGlobalObject) bool AutoJSAPI::Init(JSObject* aObject) { - return Init(xpc::NativeGlobal(aObject)); + nsIGlobalObject* global = nullptr; + if (aObject) + global = xpc::NativeGlobal(aObject); + if (global) + return Init(global); + else + return false; } bool |