Skip to content

Commit de4ed28

Browse files
committed
Prevent panic when compiled in debug mode
Signed-off-by: Joe Richey <[email protected]>
1 parent aa75260 commit de4ed28

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/mem/x86_64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub unsafe extern "C" fn memcpy(dest: *mut u8, src: *const u8, count: usize) ->
3535

3636
#[cfg_attr(all(feature = "mem", not(feature = "mangled-names")), no_mangle)]
3737
pub unsafe extern "C" fn memmove(dest: *mut u8, src: *const u8, count: usize) -> *mut u8 {
38-
let delta = dest as usize - src as usize;
38+
let delta = (dest as usize).wrapping_sub(src as usize);
3939
if delta >= count {
4040
// We can copy forwards because either dest is far enough ahead of src,
4141
// or src is ahead of dest (and delta overflowed).

0 commit comments

Comments
 (0)