Fixbug src is undefined in runtime_stubs-inl.h:415: RuntimeStArraySpread

modify the assert function call  in runtime_stubs-inl.h:415: RuntimeStArraySpread
delete the judge 'src->IsUndefined() && src->IsNull()'  in calling  assert
add an if statement to handle the case of src is Undefine and src is Null

issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I82YU2?from=project-issue

Signed-off-by: hecunmao <hecunmao@huawei.com>
Change-Id: I49c4be25d62fa97e3c4d8a2ae0b3adf621d2aa64
This commit is contained in:
hecunmao 2023-09-23 22:07:32 +08:00
parent 059023f77a
commit f98d685ad5
3 changed files with 19 additions and 2 deletions

View File

@ -412,7 +412,14 @@ JSTaggedValue RuntimeStubs::RuntimeStArraySpread(JSThread *thread, const JSHandl
JSTaggedValue index, const JSHandle<JSTaggedValue> &src)
{
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
ASSERT(dst->IsJSArray() && !src->IsNull() && !src->IsUndefined());
ASSERT(dst->IsJSArray());
if (dst->IsJSArray()) {
if (src->IsNull() || src->IsUndefined()) {
THROW_TYPE_ERROR_AND_RETURN(thread, "src is not iterable", JSTaggedValue::Exception());
}
} else {
THROW_TYPE_ERROR_AND_RETURN(thread, "dst is not iterable", JSTaggedValue::Exception());
}
if (src->IsString()) {
JSHandle<EcmaString> srcString = JSTaggedValue::ToString(thread, src);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);

View File

@ -39,3 +39,4 @@ Apple Banana
2
3
4
true

View File

@ -128,3 +128,12 @@ for (let i = 0; i < 5; ++i) {
for (let i = 0; i < 5; ++i) {
print(app.childNodes[i].childNodes[0].childNodes[0].content);
}
let result = []
try {
class C29 {};
const v66 = undefined;
new C29(...v66);
} catch (err) {
result.push(err.name == "TypeError");
}
print(result)