mirror of
https://github.com/ManchildProductions/UXP-Fixed.git
synced 2026-07-21 03:48:43 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user