Skip to content

Commit ad75a96

Browse files
committed
BTreeMap: detect bulk_steal's count-1 underflow in release builds too
1 parent 4c5c4aa commit ad75a96

File tree

1 file changed

+2
-0
lines changed
  • library/alloc/src/collections/btree

1 file changed

+2
-0
lines changed

library/alloc/src/collections/btree/node.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> {
14691469

14701470
/// This does stealing similar to `steal_left` but steals multiple elements at once.
14711471
pub fn bulk_steal_left(&mut self, count: usize) {
1472+
assert!(count > 0);
14721473
unsafe {
14731474
let left_node = &mut self.left_child;
14741475
let old_left_len = left_node.len();
@@ -1526,6 +1527,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> {
15261527

15271528
/// The symmetric clone of `bulk_steal_left`.
15281529
pub fn bulk_steal_right(&mut self, count: usize) {
1530+
assert!(count > 0);
15291531
unsafe {
15301532
let left_node = &mut self.left_child;
15311533
let old_left_len = left_node.len();

0 commit comments

Comments
 (0)