mirror of
https://github.com/bellard/quickjs.git
synced 2025-05-12 19:14:39 +08:00
fixed TypedArray.prototype.with with detached ArrayBuffer
This commit is contained in:
parent
a0a760f74f
commit
08a28c0cc3
@ -51922,6 +51922,8 @@ static JSValue js_typed_array_with(JSContext *ctx, JSValueConst this_val,
|
|||||||
p = get_typed_array(ctx, this_val, /*is_dataview*/0);
|
p = get_typed_array(ctx, this_val, /*is_dataview*/0);
|
||||||
if (!p)
|
if (!p)
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
|
if (typed_array_is_detached(ctx, p))
|
||||||
|
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
|
||||||
|
|
||||||
if (JS_ToInt64Sat(ctx, &idx, argv[0]))
|
if (JS_ToInt64Sat(ctx, &idx, argv[0]))
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
@ -51929,13 +51931,14 @@ static JSValue js_typed_array_with(JSContext *ctx, JSValueConst this_val,
|
|||||||
len = p->u.array.count;
|
len = p->u.array.count;
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
idx = len + idx;
|
idx = len + idx;
|
||||||
if (idx < 0 || idx >= len)
|
|
||||||
return JS_ThrowRangeError(ctx, "invalid array index");
|
|
||||||
|
|
||||||
val = JS_ToPrimitive(ctx, argv[1], HINT_NUMBER);
|
val = JS_ToPrimitive(ctx, argv[1], HINT_NUMBER);
|
||||||
if (JS_IsException(val))
|
if (JS_IsException(val))
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
|
|
||||||
|
if (typed_array_is_detached(ctx, p) || idx < 0 || idx >= len)
|
||||||
|
return JS_ThrowRangeError(ctx, "invalid array index");
|
||||||
|
|
||||||
arr = js_typed_array_constructor_ta(ctx, JS_UNDEFINED, this_val,
|
arr = js_typed_array_constructor_ta(ctx, JS_UNDEFINED, this_val,
|
||||||
p->class_id);
|
p->class_id);
|
||||||
if (JS_IsException(arr)) {
|
if (JS_IsException(arr)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user