Skip to content

Commit

Permalink
fix: handle unexpected EOF in PeekReader in case zero bytes has read
Browse files Browse the repository at this point in the history
  • Loading branch information
kusstas committed Dec 22, 2024
1 parent f801bea commit 771564f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mavlink-core/src/peek_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ impl<R: Read, const BUFFER_SIZE: usize> PeekReader<R, BUFFER_SIZE> {
// read needed bytes from reader
let bytes_read = self.reader.read(&mut buf[..bytes_to_read])?;

if bytes_read == 0 {
return Err(MessageReadError::Io(
std::io::ErrorKind::UnexpectedEof.into(),
));
}

// if some bytes were read, add them to the buffer

if self.buffer.len() - self.top < bytes_read {
Expand Down

0 comments on commit 771564f

Please sign in to comment.