From b2939bd867eda60d083199153fb9103fc54426bb Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 13 Apr 2020 11:29:08 +0200 Subject: [PATCH] core/io: fix bug in MemoryReader::peek_buf() --- nihav-core/src/io/byteio.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nihav-core/src/io/byteio.rs b/nihav-core/src/io/byteio.rs index 4463b2b..ba3d95c 100644 --- a/nihav-core/src/io/byteio.rs +++ b/nihav-core/src/io/byteio.rs @@ -472,7 +472,7 @@ impl<'a> ByteIO for MemoryReader<'a> { } fn peek_buf(&mut self, buf: &mut [u8]) -> ByteIOResult { - let copy_size = if self.buf.len() - self.pos < buf.len() { self.buf.len() } else { buf.len() }; + let copy_size = if self.buf.len() - self.pos < buf.len() { self.buf.len() - self.pos } else { buf.len() }; if copy_size == 0 { return Err(ByteIOError::EOF); } let dst = &mut buf[0..copy_size]; dst.copy_from_slice(&self.buf[self.pos..][..copy_size]); -- 2.39.5