Bug 1353610 - Add null checks. r=bobbyholley
authorJW Wang <jwwang@mozilla.com>
Fri, 31 Mar 2017 17:01:35 +0800
changeset 351490 678773021f14856e468bd5a32241fc8f1b680506
parent 351489 72c867371b300dc90dc5dfbe6bbf40377af6644e
child 351491 c46e2ef0d7ed9fd219ab95e0808ce596364e1fd0
push id31611
push usercbook@mozilla.com
push dateThu, 06 Apr 2017 10:51:05 +0000
treeherdermozilla-central@950612071c4e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobbyholley
bugs1353610
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1353610 - Add null checks. r=bobbyholley
xpcom/threads/TaskDispatcher.h
--- a/xpcom/threads/TaskDispatcher.h
+++ b/xpcom/threads/TaskDispatcher.h
@@ -112,33 +112,37 @@ 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);
     // To preserve the event order, we need to append a new group if the last
     // group is not targeted for |aThread|.
     // See https://bugzilla.mozilla.org/show_bug.cgi?id=1318226&mark=0-3#c0
     // for the details of the issue.
     if (mTaskGroups.Length() == 0 || mTaskGroups.LastElement()->mThread != aThread) {
       mTaskGroups.AppendElement(new PerThreadTaskGroup(aThread));
     }
 
     PerThreadTaskGroup& group = *mTaskGroups.LastElement();
-    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;
     }
   }