diff --git a/CHANGELOG.md b/CHANGELOG.md index 5df0b8ae3ab..439db8e37af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#1006](https://github.com/wasmerio/wasmer/pull/1006) Fix minor panic issue when `wasmer::compile_with` called with llvm backend - [#1009](https://github.com/wasmerio/wasmer/pull/1009) Enable LLVM verifier for all tests, add new llvm-backend-tests crate. ## 0.11.0 - 2019-11-22 diff --git a/lib/llvm-backend/src/state.rs b/lib/llvm-backend/src/state.rs index 0d46dc5c099..fde5eb52e40 100644 --- a/lib/llvm-backend/src/state.rs +++ b/lib/llvm-backend/src/state.rs @@ -240,12 +240,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(