Bug 1283017 - Fix ContentParent::GetAll() returning a dead ContentParent instance if it's the first in the list. r=billm
authorCervantes Yu <cyu@mozilla.com>
Fri, 01 Jul 2016 10:50:14 +0800
changeset 383052 8836868dd1e569fb075c32c5152782f18bf253cc
parent 383051 8616e68a5afa89c542e52b94f622309be3fee0d6
child 383053 2bca7bc98f9868885f92772f9d5d1c818fbb195b
push id21910
push userbmo:gasolin@mozilla.com
push dateFri, 01 Jul 2016 03:50:27 +0000
reviewersbillm
bugs1283017
milestone50.0a1
Bug 1283017 - Fix ContentParent::GetAll() returning a dead ContentParent instance if it's the first in the list. r=billm 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++()