From 5bb34f02dea7bc2a3f7ca475ccb1e991910d0f62 Mon Sep 17 00:00:00 2001 From: wangrx Date: Mon, 26 Feb 2024 15:42:06 +0800 Subject: [PATCH] Fix mjsunit/compiler/string-endswith.js --- ecmascript/builtins/builtins_string.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ecmascript/builtins/builtins_string.cpp b/ecmascript/builtins/builtins_string.cpp index a2d83574ed..325a2dc492 100644 --- a/ecmascript/builtins/builtins_string.cpp +++ b/ecmascript/builtins/builtins_string.cpp @@ -405,7 +405,8 @@ JSTaggedValue BuiltinsString::EndsWith(EcmaRuntimeCallInfo *argv) if (posVal.GetNumber() == BuiltinsNumber::POSITIVE_INFINITY) { pos = thisLen; } else { - pos = static_cast(posVal.ToInt32()); + // pos = static_cast(posVal.ToInt32()); + pos = static_cast(base::NumberHelper::DoubleInRangeInt32(posVal.GetNumber())); } } uint32_t end = std::min(std::max(pos, 0U), thisLen); -- Gitee