diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-06-27 02:09:19 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-06-27 02:19:50 +0200 |
commit | 1fa428a7898b213149cc4737a71e79aeb18d60cc (patch) | |
tree | f9b2505c1896a2739dce18f8167fbb651f611e8f /dom/base/ScriptSettings.cpp | |
parent | d41fe2f55a0a2d342ef5e415855bdaa62b22b389 (diff) | |
download | UXP-1fa428a7898b213149cc4737a71e79aeb18d60cc.tar UXP-1fa428a7898b213149cc4737a71e79aeb18d60cc.tar.gz UXP-1fa428a7898b213149cc4737a71e79aeb18d60cc.tar.lz UXP-1fa428a7898b213149cc4737a71e79aeb18d60cc.tar.xz UXP-1fa428a7898b213149cc4737a71e79aeb18d60cc.zip |
Issue #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/ScriptSettings.cpp')
-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 d67f2167a..92ab221c9 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 |