From a4eb46fcca88d16f193a2ae0d7ca890bb8447c88 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 30 Jun 2024 20:29:31 +0200 Subject: [PATCH] LibWasm/WASI: Don't convert enums and u8s into i64 Doing so results in incorrect values being created, ultimately leading to traps or errors. (cherry picked from commit f6c3b333334f7bb5314a844804cb259cf277005e) --- Userland/Libraries/LibWasm/WASI/Wasi.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWasm/WASI/Wasi.cpp b/Userland/Libraries/LibWasm/WASI/Wasi.cpp index d5aed595a47..cb3d7baec1c 100644 --- a/Userland/Libraries/LibWasm/WASI/Wasi.cpp +++ b/Userland/Libraries/LibWasm/WASI/Wasi.cpp @@ -909,7 +909,20 @@ ErrorOr Implementation::function_by_name(StringView name) namespace ABI { template -auto CompatibleValueType = IsOneOf +struct HostTypeImpl { + using Type = T; +}; + +template +struct HostTypeImpl { + using Type = UnderlyingType; +}; + +template +using HostType = typename HostTypeImpl::Type; + +template +auto CompatibleValueType = IsOneOf, i8, i16, i32, u8, u16> ? Wasm::ValueType(Wasm::ValueType::I32) : Wasm::ValueType(Wasm::ValueType::I64);