Skip to content

Commit 69ff39e

Browse files
committed
Auto merge of #79987 - ssomers:btree_cleanup_4, r=Mark-Simulacrum
BTreeMap: detect bulk_steal's count-1 underflow in release builds too r? `@Mark-Simulacrum`
2 parents cbab347 + ad75a96 commit 69ff39e

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
@@ -1475,6 +1475,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> {
14751475

14761476
/// This does stealing similar to `steal_left` but steals multiple elements at once.
14771477
pub fn bulk_steal_left(&mut self, count: usize) {
1478+
assert!(count > 0);
14781479
unsafe {
14791480
let left_node = &mut self.left_child;
14801481
let old_left_len = left_node.len();
@@ -1532,6 +1533,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> {
15321533

15331534
/// The symmetric clone of `bulk_steal_left`.
15341535
pub fn bulk_steal_right(&mut self, count: usize) {
1536+
assert!(count > 0);
15351537
unsafe {
15361538
let left_node = &mut self.left_child;
15371539
let old_left_len = left_node.len();

0 commit comments

Comments
 (0)