@@ -963,7 +963,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
963963 // If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required null
964964 // terminator to memory using the `ptr` pointer would cause an out-of-bounds access.
965965 let string_length = u64:: try_from ( c_str. len ( ) ) . unwrap ( ) ;
966- let string_length = string_length. checked_add ( 1 ) . unwrap ( ) ;
966+ let string_length = string_length. strict_add ( 1 ) ;
967967 if size < string_length {
968968 return Ok ( ( false , string_length) ) ;
969969 }
@@ -1027,7 +1027,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
10271027 // If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required
10281028 // 0x0000 terminator to memory would cause an out-of-bounds access.
10291029 let string_length = u64:: try_from ( wide_str. len ( ) ) . unwrap ( ) ;
1030- let string_length = string_length. checked_add ( 1 ) . unwrap ( ) ;
1030+ let string_length = string_length. strict_add ( 1 ) ;
10311031 if size < string_length {
10321032 return Ok ( ( false , string_length) ) ;
10331033 }
@@ -1391,7 +1391,7 @@ pub(crate) fn windows_check_buffer_size((success, len): (bool, u64)) -> u32 {
13911391 if success {
13921392 // If the function succeeds, the return value is the number of characters stored in the target buffer,
13931393 // not including the terminating null character.
1394- u32:: try_from ( len. checked_sub ( 1 ) . unwrap ( ) ) . unwrap ( )
1394+ u32:: try_from ( len. strict_sub ( 1 ) ) . unwrap ( )
13951395 } else {
13961396 // If the target buffer was not large enough to hold the data, the return value is the buffer size, in characters,
13971397 // required to hold the string and its terminating null character.
0 commit comments