bug 1328964 restore fix for crash in runnable after thread shutdown bug 1315446 r?jib draft
authorKarl Tomlinson <karlt+@karlt.net>
Mon, 19 Mar 2018 10:32:16 +1300
changeset 769215 ad28a55d4e1fbdfbd041b0da5111949759d5d14f
parent 769214 067bcccfcb031b8e3c44e63d8c8024d07cac2fb3
child 769216 64b42a345dcbe6b7c54fc83fb33cb912506e0111
push id103070
push userktomlinson@mozilla.com
push dateMon, 19 Mar 2018 05:04:09 +0000
reviewersjib
bugs1328964, 1315446, 199434
milestone59.0a1
bug 1328964 restore fix for crash in runnable after thread shutdown bug 1315446 r?jib Lost in rebase of "part 2 - Worklet Thread - second part" across https://hg.mozilla.org/mozilla-central/rev/df94a2bfc2436b00a776c9083cc3ae4dda01a1fe#l1.12 Addresses https://reviewboard.mozilla.org/r/199434/#comment296312 MozReview-Commit-ID: BEOsIwz8XZ8
dom/base/nsContentUtils.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -6194,17 +6194,22 @@ nsContentUtils::GetCurrentJSContext()
 JSContext *
 nsContentUtils::GetCurrentJSContextForThread()
 {
   MOZ_ASSERT(IsInitialized());
   if (MOZ_LIKELY(NS_IsMainThread())) {
     return GetCurrentJSContext();
   }
 
-  return CycleCollectedJSContext::Get()->GetWorkerWorkletSafeContext();
+  CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
+  if (!ccjscx) {
+    return nullptr;
+  }
+
+  return ccjscx->GetWorkerWorkletSafeContext();
 }
 
 template<typename StringType, typename CharType>
 void
 _ASCIIToLowerInSitu(StringType& aStr)
 {
   CharType* iter = aStr.BeginWriting();
   CharType* end = aStr.EndWriting();