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.
This commit is contained in:
parent
4ae2a54f3d
commit
8d015bd71c
Notes:
sideshowbarker
2024-07-17 05:00:08 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/8d015bd71c Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/linusg
1 changed files with 3 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue