Skip to content

Commit

Permalink
Merge pull request #8 from jorgecarleitao/fix_ub
Browse files Browse the repository at this point in the history
Fixed UB
  • Loading branch information
WanzenBug committed Jan 30, 2022
2 parents 690742a + 8f8bc47 commit d71d677
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ fn append_from_within<T>(seif: &mut Vec<T>, src: ops::Range<usize>) where T: Cop
unsafe {
// This is safe because reserve() above succeeded,
// so `seif.len() + count` did not overflow usize
ptr::copy_nonoverlapping(
seif.get_unchecked(src.start),
seif.get_unchecked_mut(vec_len),
count,
);
// Derive both `src_ptr` and `dest_ptr` from the same loan
let ptr = seif.as_mut_ptr();
let src_ptr = ptr.add(src.start);
let dest_ptr = ptr.add(vec_len);
ptr::copy_nonoverlapping(src_ptr, dest_ptr, count);
seif.set_len(vec_len + count);
}
}
Expand Down

0 comments on commit d71d677

Please sign in to comment.