Skip to content

Commit

Permalink
qcow2-rs: fix check for cluster leak
Browse files Browse the repository at this point in the history
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
  • Loading branch information
ming1 committed Jan 2, 2024
1 parent 6f90d90 commit 38d8f89
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2393,10 +2393,12 @@ impl<T: Qcow2IoOps> Qcow2Dev<T> {
_ => {}
},
MappingSource::Compressed => match mapping.cluster_offset {
Some(start) => {
let end = start + (mapping.compressed_length.unwrap() as u64);
for off in (start..=end).step_by(info.cluster_size()) {
Self::add_used_cluster_to_set(ranges, off >> info.cluster_bits());
Some(off) => {
let start = off >> info.cluster_bits();
let end = (off + (mapping.compressed_length.unwrap() as u64))
>> info.cluster_bits();
for off in start..=end {
Self::add_used_cluster_to_set(ranges, off);
}
allocated += 1;
compressed += 1;
Expand Down

0 comments on commit 38d8f89

Please sign in to comment.