From 38b8fa8f3e2f0ff0174b9cb9bd7345b74b155931 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Wed, 30 Jun 2021 19:50:23 +0300 Subject: [PATCH] LibJS: Ensure shift values in left_shift are modded by 32 This is equivalent to 58d6a2d0192b7860ecb2edb4aa5d36b389213a15 but for the left shift operation. --- Userland/Libraries/LibJS/Runtime/Value.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index dafa672468e..0c8742b2f07 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -993,7 +993,7 @@ Value left_shift(GlobalObject& global_object, Value lhs, Value rhs) return lhs_numeric; // Ok, so this performs toNumber() again but that "can't" throw auto lhs_i32 = lhs_numeric.to_i32(global_object); - auto rhs_u32 = rhs_numeric.to_u32(global_object); + auto rhs_u32 = rhs_numeric.to_u32(global_object) % 32; return Value(lhs_i32 << rhs_u32); } if (both_bigint(lhs_numeric, rhs_numeric)) {