Bug 1283017 - Fix ContentParent::GetAll() returning a dead ContentParent instance if it's the first in the list. r=billm, a=lizzard
authorCervantes Yu <cyu@mozilla.com>
Fri, 01 Jul 2016 10:50:14 +0800
changeset 341976 4f2339c77cfcd694eed4d7261491d5791ac735b6
parent 341975 a1269ccfe4c13e0b2ea9334ad42f292d910b90bf
child 341977 1c72f075dd79e2f4013909681c7541d4e2275345
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, lizzard
bugs1283017
milestone49.0a2
Bug 1283017 - Fix ContentParent::GetAll() returning a dead ContentParent instance if it's the first in the list. r=billm, a=lizzard MozReview-Commit-ID: HqkNRsAcHlP
dom/ipc/ContentParent.h
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -180,16 +180,21 @@ public:
     ContentParentIterator(CPIteratorPolicy aPolicy, ContentParent* aCurrent)
       : mCurrent(aCurrent),
         mPolicy(aPolicy)
     {
     }
 
     ContentParentIterator begin()
     {
+      // Move the cursor to the first element that matches the policy.
+      while (mPolicy != eAll && mCurrent && !mCurrent->mIsAlive) {
+        mCurrent = mCurrent->LinkedListElement<ContentParent>::getNext();
+      }
+
       return *this;
     }
     ContentParentIterator end()
     {
       return ContentParentIterator(mPolicy, nullptr);
     }
 
     const ContentParentIterator& operator++()