From a3a90620419e8943e30ba5ae17048433ce5b2f14 Mon Sep 17 00:00:00 2001 From: wangrx Date: Tue, 26 Mar 2024 13:59:50 +0800 Subject: [PATCH] fix mjsunit/harmony/relative-indexing-methods.js --- ecmascript/builtins/builtins_string.cpp | 3 ++- ecmascript/builtins/builtins_typedarray.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ecmascript/builtins/builtins_string.cpp b/ecmascript/builtins/builtins_string.cpp index 1b432a0410..c539c576a1 100644 --- a/ecmascript/builtins/builtins_string.cpp +++ b/ecmascript/builtins/builtins_string.cpp @@ -2086,7 +2086,8 @@ JSTaggedValue BuiltinsString::Pad(EcmaRuntimeCallInfo *argv, bool isStart) int32_t BuiltinsString::ConvertDoubleToInt(double d) { - if (std::isnan(d) || d == -base::POSITIVE_INFINITY) { + // If number is one of NaN, +0𝔽, or -0𝔽, return 0 + if (std::isnan(d) || d == -0) { return 0; } if (d >= static_cast(INT_MAX)) { diff --git a/ecmascript/builtins/builtins_typedarray.cpp b/ecmascript/builtins/builtins_typedarray.cpp index 3edc30c363..453e902407 100644 --- a/ecmascript/builtins/builtins_typedarray.cpp +++ b/ecmascript/builtins/builtins_typedarray.cpp @@ -1971,6 +1971,11 @@ JSTaggedValue BuiltinsTypedArray::At(EcmaRuntimeCallInfo *argv) if (!thisHandle->IsTypedArray()) { THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "This is not a TypedArray.", JSTaggedValue::Exception()); } + JSTaggedValue buffer = JSHandle::Cast(thisHandle)->GetViewedArrayBufferOrByteArray(); + if (BuiltinsArrayBuffer::IsDetachedBuffer(buffer)) { + THROW_TYPE_ERROR_AND_RETURN(thread, "The targetBuffer of This value is detached buffer.", + JSTaggedValue::Exception()); + } JSHandle thisObjHandle = JSTaggedValue::ToObject(thread, thisHandle); // ReturnIfAbrupt(O). RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); -- Gitee