diff options
| author | bors <bors@rust-lang.org> | 2020-12-13 17:09:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-12-13 17:09:41 +0000 |
| commit | 69ff39ee32ce73e407725cbd90cafdb23cb7ec68 (patch) | |
| tree | ec240c800a4dcf1d35128113456efc481d453ece | |
| parent | cbab347e68d31cba63105f966617a86758134a8f (diff) | |
| parent | ad75a96b34c0c52036c7e903cc97816cdba150f8 (diff) | |
| download | rust-69ff39ee32ce73e407725cbd90cafdb23cb7ec68.tar.gz rust-69ff39ee32ce73e407725cbd90cafdb23cb7ec68.zip | |
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`
| -rw-r--r-- | library/alloc/src/collections/btree/node.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index 07667fa2288..22e60309a2c 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -1475,6 +1475,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// This does stealing similar to `steal_left` but steals multiple elements at once. pub fn bulk_steal_left(&mut self, count: usize) { + assert!(count > 0); unsafe { let left_node = &mut self.left_child; let old_left_len = left_node.len(); @@ -1532,6 +1533,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { /// The symmetric clone of `bulk_steal_left`. pub fn bulk_steal_right(&mut self, count: usize) { + assert!(count > 0); unsafe { let left_node = &mut self.left_child; let old_left_len = left_node.len(); |
