Skip to content

Commit

Permalink
fix unsound pointer arithmetic (#185)
Browse files Browse the repository at this point in the history
Closes #177
  • Loading branch information
krasimirgg authored Sep 30, 2024
1 parent 42422dc commit cf69365
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a> Bytes<'a> {
pub fn peek_ahead(&self, n: usize) -> Option<u8> {
// SAFETY: obtain a potentially OOB pointer that is later compared against the `self.end`
// pointer.
let ptr = unsafe { self.cursor.add(n) };
let ptr = self.cursor.wrapping_add(n);
if ptr < self.end {
// SAFETY: bounds checked pointer dereference is safe
Some(unsafe { *ptr })
Expand Down

0 comments on commit cf69365

Please sign in to comment.