mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1301519 Don't crash if GetCurrentThreadWorkerPrivate() is called during worker shutdown. r=baku
This commit is contained in:
parent
f3ce2c3276
commit
8df5d9263a
@ -1437,7 +1437,9 @@ GetWorkerPrivateFromContext(JSContext* aCx)
|
||||
MOZ_ASSERT(aCx);
|
||||
|
||||
void* cxPrivate = JS_GetContextPrivate(aCx);
|
||||
MOZ_ASSERT(cxPrivate);
|
||||
if (!cxPrivate) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return
|
||||
static_cast<WorkerThreadContextPrivate*>(cxPrivate)->GetWorkerPrivate();
|
||||
@ -1457,7 +1459,13 @@ GetCurrentThreadWorkerPrivate()
|
||||
MOZ_ASSERT(cx);
|
||||
|
||||
void* cxPrivate = JS_GetContextPrivate(cx);
|
||||
MOZ_ASSERT(cxPrivate);
|
||||
if (!cxPrivate) {
|
||||
// This can happen if the nsCycleCollector_shutdown() in ~WorkerJSRuntime()
|
||||
// triggers any calls to GetCurrentThreadWorkerPrivate(). At this stage
|
||||
// CycleCollectedJSRuntime::Get() will still return a runtime, but
|
||||
// the context private has already been cleared.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return
|
||||
static_cast<WorkerThreadContextPrivate*>(cxPrivate)->GetWorkerPrivate();
|
||||
|
Loading…
Reference in New Issue
Block a user