diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2021-11-12 11:37:24 +0100 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2021-11-12 11:37:24 +0100 |
commit | f88724a81e18ae9521863faf94ae9d2c2cb60e15 (patch) | |
tree | 7d67981dc2cb9060af244a4c2aecb0d1391b4df6 | |
parent | ef0b99e68b6dd253074ed36e1dc665231e91b3b3 (diff) | |
download | nihav-f88724a81e18ae9521863faf94ae9d2c2cb60e15.tar.gz |
core/byteio: fix corner case when reading partial buffer at the end of file
-rw-r--r-- | nihav-core/src/io/byteio.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/nihav-core/src/io/byteio.rs b/nihav-core/src/io/byteio.rs index 3fbee94..b3d0621 100644 --- a/nihav-core/src/io/byteio.rs +++ b/nihav-core/src/io/byteio.rs @@ -600,8 +600,11 @@ impl<T: Read+Seek> ByteIO for FileReader<T> { if ret.is_err() { return Err(ByteIOError::ReadError); } let sz = ret.unwrap(); if sz < buf.len() { - if let Err(_err) = self.file.read(&mut buf[sz..][..1]) { + if let Err(_err) = self.file.read_exact(&mut buf[sz..][..1]) { self.eof = true; + if sz == 0 { + return Err(ByteIOError::EOF); + } } else { return Ok(sz + 1); } |