Bug 1353610 - Add null checks. r=bobbyholley, a=gchang
authorJW Wang <jwwang@mozilla.com>
Mon, 10 Apr 2017 15:06:10 +0800
changeset 395805 c189e40723ec806949e569d1c003df65da34d2cb
parent 395804 c4eb93e5c5d4aa0ac3377e9c6b77993498d17acf
child 395806 8da95adec5a778ce8c5f596aa5c9eda880002fe5
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobbyholley, gchang
bugs1353610
milestone54.0a2
Bug 1353610 - Add null checks. r=bobbyholley, a=gchang
xpcom/threads/TaskDispatcher.h
--- a/xpcom/threads/TaskDispatcher.h
+++ b/xpcom/threads/TaskDispatcher.h
@@ -112,25 +112,29 @@ public:
       mDirectTasks.emplace();
     }
     mDirectTasks->push(Move(aRunnable));
   }
 
   void AddStateChangeTask(AbstractThread* aThread,
                           already_AddRefed<nsIRunnable> aRunnable) override
   {
-    EnsureTaskGroup(aThread).mStateChangeTasks.AppendElement(aRunnable);
+    nsCOMPtr<nsIRunnable> r = aRunnable;
+    MOZ_RELEASE_ASSERT(r);
+    EnsureTaskGroup(aThread).mStateChangeTasks.AppendElement(r.forget());
   }
 
   void AddTask(AbstractThread* aThread,
                already_AddRefed<nsIRunnable> aRunnable,
                AbstractThread::DispatchFailureHandling aFailureHandling) override
   {
+    nsCOMPtr<nsIRunnable> r = aRunnable;
+    MOZ_RELEASE_ASSERT(r);
     PerThreadTaskGroup& group = EnsureTaskGroup(aThread);
-    group.mRegularTasks.AppendElement(aRunnable);
+    group.mRegularTasks.AppendElement(r.forget());
 
     // The task group needs to assert dispatch success if any of the runnables
     // it's dispatching want to assert it.
     if (aFailureHandling == AbstractThread::AssertDispatchSuccess) {
       group.mFailureHandling = AbstractThread::AssertDispatchSuccess;
     }
   }