Mercurial > hg
changeset 49134:8c59d8adcf5b
rust-dirstatemap: use a checked sub instead of a potentially underflowing one
This was missed in 2593873cda0f
Differential Revision: https://phab.mercurial-scm.org/D12532
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Fri, 08 Apr 2022 18:10:12 +0200 |
parents | 23a5659125c8 |
children | a1fce5003ff4 |
files | rust/hg-core/src/dirstate_tree/dirstate_map.rs |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs Fri Apr 08 17:55:03 2022 +0200 +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs Fri Apr 08 18:10:12 2022 +0200 @@ -1337,7 +1337,9 @@ )? .and_then(|node| { if let Some(source) = &node.copy_source { - *count -= 1; + *count = count + .checked_sub(1) + .expect("nodes_with_copy_source_count should be >= 0"); DirstateMap::count_dropped_path(unreachable_bytes, source); } node.copy_source.take().map(Cow::into_owned)