diff --git a/mavlink-core/src/peek_reader.rs b/mavlink-core/src/peek_reader.rs index 47eb874cb1..8b316d7ad0 100644 --- a/mavlink-core/src/peek_reader.rs +++ b/mavlink-core/src/peek_reader.rs @@ -134,6 +134,12 @@ impl PeekReader { // 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 {