1006: fix 1005 panic sub overflow r=MarkMcCaskey a=pventuzelo

# Description

Fix issue https://github.com/wasmerio/wasmer/issues/1005

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Patrick Ventuzelo <ventuzelo.patrick@gmail.com>
Co-authored-by: Patrick Ventuzelo <9038181+pventuzelo@users.noreply.github.com>
This commit is contained in:
bors[bot]
2019-11-27 00:36:29 +00:00
committed by GitHub
2 changed files with 7 additions and 6 deletions

View File

@ -336,12 +336,12 @@ impl State {
&self,
n: usize,
) -> Result<&[(BasicValueEnum, ExtraInfo)], BinaryReaderError> {
self.stack
.get(self.stack.len() - n..)
.ok_or(BinaryReaderError {
message: "invalid value stack",
offset: -1isize as usize,
})
let new_len = self.stack.len().checked_sub(n).ok_or(BinaryReaderError {
message: "invalid value stack",
offset: -1isize as usize,
})?;
Ok(&self.stack[new_len..])
}
pub fn popn_save_extra(