fix crash when add property maybe failed on build arguments

This commit is contained in:
Penner 2024-11-25 17:20:00 +08:00
parent 6e2e68fd08
commit 1dafd6b04f

View File

@ -14855,6 +14855,10 @@ static JSValue js_build_arguments(JSContext *ctx, int argc, JSValueConst *argv)
/* add the length field (cannot fail) */
pr = add_property(ctx, p, JS_ATOM_length,
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
if (!pr) {
JS_FreeValue(ctx, val);
return JS_EXCEPTION;
}
pr->u.value = JS_NewInt32(ctx, argc);
/* initialize the fast array part */
@ -14904,6 +14908,8 @@ static JSValue js_build_mapped_arguments(JSContext *ctx, int argc,
/* add the length field (cannot fail) */
pr = add_property(ctx, p, JS_ATOM_length,
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
if (!pr)
goto fail;
pr->u.value = JS_NewInt32(ctx, argc);
for(i = 0; i < arg_count; i++) {