-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
src/parser.rs:
pub struct LineReader<'a> {
pub buf: &'a [u8],
line: usize,
}
impl<'a> LineReader<'a> {
...
pub fn parse_numbers(&self) -> Result<(u32, u32, u32, u32)> {
// we know that line is beginning with "@@ -"
let buf = unsafe { self.buf.get_unchecked(4..) };
...
}
}Hi there, the struct LineReader has a public field buf, the safe public function parse_numbers use it with unsafe function get_unchecked, which violated the safety requirements mentioned in here. This could cause memory issues if buf changed to other array less then 4, even when no unsafe function involved.
Suggestion:
- make
bufprivate - Or make
parse_numbersto unsafe.
Metadata
Metadata
Assignees
Labels
No labels