mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:37:35 +00:00
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
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));
|
double_value = TRY(argument.to_double(vm));
|
||||||
switch (param.kind()) {
|
switch (param.kind()) {
|
||||||
case Wasm::ValueType::Kind::I32:
|
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;
|
break;
|
||||||
case Wasm::ValueType::Kind::I64:
|
case Wasm::ValueType::Kind::I64:
|
||||||
if (argument.is_bigint()) {
|
if (argument.is_bigint()) {
|
||||||
auto value = TRY(argument.to_bigint_int64(vm));
|
auto value = TRY(argument.to_bigint_int64(vm));
|
||||||
arguments.append(Wasm::Value(param, bit_cast<u64>(value)));
|
arguments.append(Wasm::Value(param, value));
|
||||||
} else {
|
} else {
|
||||||
arguments.append(Wasm::Value(param, static_cast<u64>(double_value)));
|
arguments.append(Wasm::Value(param, static_cast<i64>(double_value)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Wasm::ValueType::Kind::F32:
|
case Wasm::ValueType::Kind::F32:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue