@@ -973,7 +973,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
973973 // If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required null
974974 // terminator to memory using the `ptr` pointer would cause an out-of-bounds access.
975975 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 ) ;
977977 if size < string_length {
978978 return Ok ( ( false , string_length) ) ;
979979 }
@@ -1037,7 +1037,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
10371037 // If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required
10381038 // 0x0000 terminator to memory would cause an out-of-bounds access.
10391039 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 ) ;
10411041 if size < string_length {
10421042 return Ok ( ( false , string_length) ) ;
10431043 }
@@ -1406,7 +1406,7 @@ pub(crate) fn windows_check_buffer_size((success, len): (bool, u64)) -> u32 {
14061406 if success {
14071407 // If the function succeeds, the return value is the number of characters stored in the target buffer,
14081408 // 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 ( )
14101410 } else {
14111411 // If the target buffer was not large enough to hold the data, the return value is the buffer size, in characters,
14121412 // required to hold the string and its terminating null character.
0 commit comments