mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-14 14:45:40 +00:00
fix(runtime-core) Fix a panic when generating globals.
Fix https://github.com/wasmerio/wasmer/issues/979. When we try to get a global that doesn't exist, a panic is generated. This patch just skip that path, and let a proper error be generated later. With this patch, we get: ```sh $ cargo run -- run panic_index_oob_all_backends.wasm Error: ExportNotFound { name: "main" } ``` which is kind of the expected behavior in such situation.
This commit is contained in:
parent
8efa8e299c
commit
a9e446b5cd
@ -450,6 +450,11 @@ impl LocalBacking {
|
||||
let value = match &global_init.init {
|
||||
Initializer::Const(value) => value.clone(),
|
||||
Initializer::GetGlobal(import_global_index) => {
|
||||
// Skip if the global hasn't been initialized properly.
|
||||
if imports.globals.len() <= import_global_index.index() {
|
||||
continue;
|
||||
}
|
||||
|
||||
imports.globals[*import_global_index].get()
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user