From 13aee1b780ab9997352aedf0f3d90844bce658a8 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 8 Feb 2022 22:24:58 +0200 Subject: [PATCH] LibJS: Compare types instead of sizes in %TypedArray%.prototype.set Just checking for a matching size is not enough, since floats and ints have the same size, but are represented completely differently. --- Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index 1cb47f9e5e..61d799fad7 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -725,7 +725,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::set) auto limit = checked_limit.value(); // 24. If srcType is the same as targetType, then - if (source_typed_array.element_size() == typed_array->element_size()) { + if (source_typed_array.element_name() == typed_array->element_name()) { // a. NOTE: If srcType and targetType are the same, the transfer must be performed in a manner that preserves the bit-level encoding of the source data. // b. Repeat, while targetByteIndex < limit, // i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, Uint8, true, Unordered).