Skip to content

Commit

Permalink
Fix strict provenance use of pointers (#100)
Browse files Browse the repository at this point in the history
This fixes a failure when testing in miri with strict provenance. I don't believe this would lead to miscompilations, but is a good improvement to have.
  • Loading branch information
jamesmunns authored Apr 10, 2023
1 parent 62c0547 commit 978b561
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ser/flavors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ pub struct Slice<'a> {
impl<'a> Slice<'a> {
/// Create a new `Slice` flavor from a given backing buffer
pub fn new(buf: &'a mut [u8]) -> Self {
let ptr = buf.as_mut_ptr();
Slice {
start: buf.as_mut_ptr(),
cursor: buf.as_mut_ptr(),
end: unsafe { buf.as_mut_ptr().add(buf.len()) },
start: ptr,
cursor: ptr,
end: unsafe { ptr.add(buf.len()) },
_pl: PhantomData,
}
}
Expand Down

0 comments on commit 978b561

Please sign in to comment.