@@ -973,7 +973,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
973
973
// If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required null
974
974
// terminator to memory using the `ptr` pointer would cause an out-of-bounds access.
975
975
let string_length = u64:: try_from ( c_str. len ( ) ) . unwrap ( ) ;
976
- let string_length = string_length. checked_add ( 1 ) . unwrap ( ) ;
976
+ let string_length = string_length. strict_add ( 1 ) ;
977
977
if size < string_length {
978
978
return Ok ( ( false , string_length) ) ;
979
979
}
@@ -1037,7 +1037,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1037
1037
// If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required
1038
1038
// 0x0000 terminator to memory would cause an out-of-bounds access.
1039
1039
let string_length = u64:: try_from ( wide_str. len ( ) ) . unwrap ( ) ;
1040
- let string_length = string_length. checked_add ( 1 ) . unwrap ( ) ;
1040
+ let string_length = string_length. strict_add ( 1 ) ;
1041
1041
if size < string_length {
1042
1042
return Ok ( ( false , string_length) ) ;
1043
1043
}
@@ -1406,7 +1406,7 @@ pub(crate) fn windows_check_buffer_size((success, len): (bool, u64)) -> u32 {
1406
1406
if success {
1407
1407
// If the function succeeds, the return value is the number of characters stored in the target buffer,
1408
1408
// not including the terminating null character.
1409
- u32:: try_from ( len. checked_sub ( 1 ) . unwrap ( ) ) . unwrap ( )
1409
+ u32:: try_from ( len. strict_sub ( 1 ) ) . unwrap ( )
1410
1410
} else {
1411
1411
// If the target buffer was not large enough to hold the data, the return value is the buffer size, in characters,
1412
1412
// required to hold the string and its terminating null character.
0 commit comments