mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 00:38:39 +09: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:
parent
61e78cda6a
commit
179fd7df8a
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue