Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed May 21, 2020
1 parent c5b7d9f commit 894a726
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/memcpy/memcpy.rs
Expand Up @@ -15,6 +15,11 @@ fn memcpy_assert(dst: *mut u8, src: *const u8, bytes: usize) {

let size_fits_in_signed_offset = bytes <= isize::max_value() as usize;
debug_assert!(size_fits_in_signed_offset);

let dst_does_not_overflow = (dst as usize).checked_add(bytes).is_some();
let src_does_not_overflow = (src as usize).checked_add(bytes).is_some();
assert!(dst_does_not_overflow);
assert!(src_does_not_overflow);
}

pub mod memcpy_offset;
Expand Down

0 comments on commit 894a726

Please sign in to comment.