From 8d015bd71c23ea4cbc964139569797d687b1230c Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Fri, 23 Dec 2022 22:22:41 -0700 Subject: 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. --- Tests/LibWasm/test-wasm.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Tests') 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(double_value))); + arguments.append(Wasm::Value(param, static_cast(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(value))); + arguments.append(Wasm::Value(param, value)); } else { - arguments.append(Wasm::Value(param, static_cast(double_value))); + arguments.append(Wasm::Value(param, static_cast(double_value))); } break; case Wasm::ValueType::Kind::F32: -- cgit v1.2.3