Bug 1398543 - Add missing condition in DoublyLinkedList::ElementNotInList. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Sun, 10 Sep 2017 08:49:56 +0900
changeset 429635 650520572447ba9daeb09e05da0204a4dc83ca7e
parent 429634 9bc9a098e92bba80e9c9b7a719587815f115168a
child 429636 6616cbb6460fdf486e447248aec1f9803db4acdb
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1398543
milestone57.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 1398543 - Add missing condition in DoublyLinkedList::ElementNotInList. r=froydnj
mfbt/DoublyLinkedList.h
--- a/mfbt/DoublyLinkedList.h
+++ b/mfbt/DoublyLinkedList.h
@@ -112,18 +112,25 @@ class DoublyLinkedList final
   /**
    * Checks that either the list is empty and both mHead and mTail are nullptr
    * or the list has entries and both mHead and mTail are non-null.
    */
   bool isStateValid() const {
     return (mHead != nullptr) == (mTail != nullptr);
   }
 
-  static bool ElementNotInList(T* aElm) {
-    return !SiblingAccess::GetNext(aElm) && !SiblingAccess::GetPrev(aElm);
+  bool ElementNotInList(T* aElm) {
+    if (!SiblingAccess::GetNext(aElm) && !SiblingAccess::GetPrev(aElm)) {
+      // Both mNext and mPrev being NULL can mean two things:
+      // - the element is not in the list.
+      // - the element is the first and only element in the list.
+      // So check for the latter.
+      return mHead != aElm;
+    }
+    return false;
   }
 
 public:
   DoublyLinkedList() : mHead(nullptr), mTail(nullptr) {}
 
   class Iterator final {
     T* mCurrent;