Fix access to VMMemoryDefinition::current_length on big-endian (#3013)
The current_length member is defined as "usize" in Rust code, but generated wasm code refers to it as if it were "u32". While this happens to mostly work on little-endian machines (as long as the length is < 4GB), it will always fail on big-endian machines. Fixed by making current_length "u32" in Rust as well, and ensuring the actual memory size is always less than 4GB.
This commit is contained in:
@@ -55,7 +55,7 @@ fn linear_memory_limits() -> Result<()> {
|
||||
fn test(engine: &Engine) -> Result<()> {
|
||||
let wat = r#"
|
||||
(module
|
||||
(memory 65535)
|
||||
(memory 65534)
|
||||
|
||||
(func (export "foo") (result i32)
|
||||
i32.const 1
|
||||
@@ -68,7 +68,7 @@ fn linear_memory_limits() -> Result<()> {
|
||||
let instance = Instance::new(&mut store, &module, &[])?;
|
||||
let foo = instance.get_typed_func::<(), i32, _>(&mut store, "foo")?;
|
||||
|
||||
assert_eq!(foo.call(&mut store, ())?, 65535);
|
||||
assert_eq!(foo.call(&mut store, ())?, 65534);
|
||||
assert_eq!(foo.call(&mut store, ())?, -1);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user