mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 22:28:21 +00:00
Make globals non leaking
This commit is contained in:
@@ -10,8 +10,8 @@ use wasm_common::entity::PrimaryMap;
|
||||
use wasm_common::FuncType;
|
||||
use wasm_common::{
|
||||
DataIndex, DataInitializer, DataInitializerLocation, ElemIndex, ExportIndex, FuncIndex,
|
||||
GlobalIndex, GlobalType, ImportIndex, LocalFuncIndex, MemoryIndex, MemoryType, SignatureIndex,
|
||||
TableIndex, TableType,
|
||||
GlobalIndex, GlobalInit, GlobalType, ImportIndex, LocalFuncIndex, MemoryIndex, MemoryType,
|
||||
SignatureIndex, TableIndex, TableType,
|
||||
};
|
||||
use wasmer_runtime::{Module, TableElements};
|
||||
|
||||
@@ -263,8 +263,13 @@ impl<'data> ModuleEnvironment<'data> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn declare_global(&mut self, global: GlobalType) -> WasmResult<()> {
|
||||
pub(crate) fn declare_global(
|
||||
&mut self,
|
||||
global: GlobalType,
|
||||
initializer: GlobalInit,
|
||||
) -> WasmResult<()> {
|
||||
self.result.module.globals.push(global);
|
||||
self.result.module.global_initializers.push(initializer);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,6 @@ pub fn parse_import_section<'data>(
|
||||
GlobalType {
|
||||
ty: wptype_to_type(ty.content_type).unwrap(),
|
||||
mutability: ty.mutable.into(),
|
||||
initializer: GlobalInit::Import,
|
||||
},
|
||||
module_name,
|
||||
field_name,
|
||||
@@ -254,9 +253,8 @@ pub fn parse_global_section(
|
||||
let global = GlobalType {
|
||||
ty: wptype_to_type(content_type).unwrap(),
|
||||
mutability: mutable.into(),
|
||||
initializer,
|
||||
};
|
||||
environ.declare_global(global)?;
|
||||
environ.declare_global(global, initializer)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user