diff options
author | Andrew Kaster <akaster@serenityos.org> | 2022-12-23 22:22:41 -0700 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-25 07:58:58 -0700 |
commit | 8d015bd71c23ea4cbc964139569797d687b1230c (patch) | |
tree | c54c16bf45c3697ca83006ff04af1ba983ad0c03 /Tests | |
parent | 4ae2a54f3dc8f5066811f7c9b4fcd613a1d230c9 (diff) | |
download | serenity-8d015bd71c23ea4cbc964139569797d687b1230c.zip |
test-wasm: Don't cast signed values to unsigned types in wasm_invoke
If a negative value ends up in one of the arguments for an invoked
function, we don't want to cast it from a floating point type to an
unsigned type. This fixes a float-cast-overflow UBSAN error on macOS
with llvm 15.0.6.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibWasm/test-wasm.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index 122d2cbdf7..44bc43d7a5 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -211,14 +211,14 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke) double_value = TRY(argument.to_double(vm)); switch (param.kind()) { case Wasm::ValueType::Kind::I32: - arguments.append(Wasm::Value(param, static_cast<u64>(double_value))); + arguments.append(Wasm::Value(param, static_cast<i64>(double_value))); break; case Wasm::ValueType::Kind::I64: if (argument.is_bigint()) { auto value = TRY(argument.to_bigint_int64(vm)); - arguments.append(Wasm::Value(param, bit_cast<u64>(value))); + arguments.append(Wasm::Value(param, value)); } else { - arguments.append(Wasm::Value(param, static_cast<u64>(double_value))); + arguments.append(Wasm::Value(param, static_cast<i64>(double_value))); } break; case Wasm::ValueType::Kind::F32: |