wasm_interp: create a new error MemoryAccessOutOfBounds

This commit is contained in:
Brian Carroll 2023-05-07 07:39:01 +01:00 committed by Folkert
parent 17d8ef2aa7
commit a3b5a9d9a2
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 21 additions and 3 deletions

View file

@ -67,6 +67,7 @@ impl<'a> ImportDispatcher for DefaultImportDispatcher<'a> {
pub(crate) enum Error {
Type(ValueType, ValueType),
StackEmpty,
MemoryAccessOutOfBounds(u32, u32),
UnreachableOp,
}
@ -85,6 +86,12 @@ impl Error {
file_offset
)
}
Error::MemoryAccessOutOfBounds(addr, memory_size) => {
format!(
"ERROR: A Wasm instruction at file offset {:#x} tried to access memory at {:#x} but the maximum address is {:#x}\n",
file_offset, addr, memory_size-1
)
}
Error::UnreachableOp => {
format!(
"WebAssembly `unreachable` instruction at file offset {:#x}.\n",