Fix handling of empty slice in Instructions
The code would've taken one element when an empty slice was requested. Co-authored-by: Tobin C. Harding <me@tobin.cc>
This commit is contained in:
parent
e6ff754b73
commit
2c28d3b448
|
@ -746,7 +746,10 @@ impl<'a> Instructions<'a> {
|
|||
fn take_slice_or_kill(&mut self, len: usize) -> Result<&'a [u8], Error> {
|
||||
if self.data.len() >= len {
|
||||
let slice = &self.data.as_slice()[..len];
|
||||
self.data.nth(len.max(1) - 1);
|
||||
if len > 0 {
|
||||
self.data.nth(len - 1);
|
||||
}
|
||||
|
||||
Ok(slice)
|
||||
} else {
|
||||
self.kill();
|
||||
|
|
Loading…
Reference in New Issue