block: vhdx: use checked_add in read and write functions

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2025-01-03 05:31:58 +00:00 committed by Wei Liu
parent 463c9b8e56
commit bc4a1fd16c

View File

@ -119,7 +119,7 @@ impl Read for Vhdx {
) )
})?; })?;
self.current_offset += result as u64; self.current_offset = self.current_offset.checked_add(result as u64).unwrap();
Ok(result) Ok(result)
} }
@ -164,7 +164,7 @@ impl Write for Vhdx {
) )
})?; })?;
self.current_offset += result as u64; self.current_offset = self.current_offset.checked_add(result as u64).unwrap();
Ok(result) Ok(result)
} }