diff options
| author | Stein Somers <git@steinsomers.be> | 2020-11-23 14:41:53 +0100 |
|---|---|---|
| committer | Stein Somers <git@steinsomers.be> | 2020-12-13 00:37:30 +0100 |
| commit | ad75a96b34c0c52036c7e903cc97816cdba150f8 (patch) | |
| tree | 64f4e833177d90321c74fe4f6359529bfb9764c2 /library/alloc | |
| parent | 4c5c4aa00203b6a5aa2352d16c3d8e4fb1ad23ee (diff) | |
| download | rust-ad75a96b34c0c52036c7e903cc97816cdba150f8.tar.gz rust-ad75a96b34c0c52036c7e903cc97816cdba150f8.zip | |
BTreeMap: detect bulk_steal's count-1 underflow in release builds too
Diffstat (limited to 'library/alloc')
| -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 31809fde57b..ffa18201431 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -1469,6 +1469,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(); @@ -1526,6 +1527,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(); |
