diff --git a/ecmascript/builtins/builtins_string.cpp b/ecmascript/builtins/builtins_string.cpp index 1b432a0410e317dc286c8e53b9d8ffeab9f0eec6..c539c576a155d6fa19093626addd7c28ebf17e40 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 3edc30c3636dc18dc846a3371e6c2fb873d39c9e..453e90240731481c6a58b430b073426e114d1c6c 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);