diff --git a/crossbeam-skiplist/src/base.rs b/crossbeam-skiplist/src/base.rs index 1ab4f8577..0e61ca100 100644 --- a/crossbeam-skiplist/src/base.rs +++ b/crossbeam-skiplist/src/base.rs @@ -1123,9 +1123,8 @@ where break; } } - - return Some(entry); } + return Some(entry); } } } @@ -1893,7 +1892,13 @@ where pub fn next(&mut self, guard: &Guard) -> Option> { self.parent.check_guard(guard); self.head = match self.head { - Some(ref e) => e.next(guard), + Some(ref e) => { + let next_head = e.next(guard); + unsafe { + e.node.decrement(guard); + } + next_head + } None => try_pin_loop(|| self.parent.lower_bound(self.range.start_bound(), guard)), }; let mut finished = false; @@ -1904,6 +1909,9 @@ where }; if !below_upper_bound(&bound, h.key().borrow()) { finished = true; + unsafe { + h.node.decrement(guard); + } } } if finished { @@ -1917,7 +1925,13 @@ where pub fn next_back(&mut self, guard: &Guard) -> Option> { self.parent.check_guard(guard); self.tail = match self.tail { - Some(ref e) => e.prev(guard), + Some(ref e) => { + let next_tail = e.prev(guard); + unsafe { + e.node.decrement(guard); + } + next_tail + } None => try_pin_loop(|| self.parent.upper_bound(self.range.start_bound(), guard)), }; let mut finished = false; @@ -1928,6 +1942,9 @@ where }; if !above_lower_bound(&bound, t.key().borrow()) { finished = true; + unsafe { + t.node.decrement(guard); + } } } if finished {