From 0af88c972fdc2c699307a2c9c0a03d98cfe5dca7 Mon Sep 17 00:00:00 2001 From: mingyix <13926077+mingyix@user.noreply.gitee.com> Date: Wed, 20 Mar 2024 09:22:05 +0800 Subject: [PATCH] [fixbug][es6/typedarray-reverse.js]If IsDetachedBuffer expected typedError. --- ecmascript/builtins/builtins_typedarray.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ecmascript/builtins/builtins_typedarray.cpp b/ecmascript/builtins/builtins_typedarray.cpp index dec628b84..ad02c9e88 100644 --- a/ecmascript/builtins/builtins_typedarray.cpp +++ b/ecmascript/builtins/builtins_typedarray.cpp @@ -1181,6 +1181,13 @@ JSTaggedValue BuiltinsTypedArray::Reverse(EcmaRuntimeCallInfo *argv) lowerValueHandle = JSArray::FastGetPropertyByValue(thread, thisObjVal, lowerP); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); upperValueHandle = JSArray::FastGetPropertyByValue(thread, thisObjVal, upperP); + + JSTaggedValue buffer = JSHandle::Cast(thisObjVal)->GetViewedArrayBufferOrByteArray(); + if (BuiltinsArrayBuffer::IsDetachedBuffer(buffer)) { + THROW_TYPE_ERROR_AND_RETURN(argv->GetThread(), "The ArrayBuffer of typedArray is detached buffer.", + JSTaggedValue::Exception()); + } + JSArray::FastSetPropertyByValue(thread, thisObjVal, lowerP, upperValueHandle); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); JSArray::FastSetPropertyByValue(thread, thisObjVal, upperP, lowerValueHandle); -- Gitee