Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -58167,13 +58167,14 @@ static JSValue js_array_buffer_transfer(JSContext *ctx, JSValueConst this_val,
return JS_EXCEPTION;
if (abuf->shared)
return JS_ThrowTypeError(ctx, "cannot transfer a SharedArrayBuffer");
if (magic == JS_ARRAY_BUFFER_TRANSFER_TO_IMMUTABLE && abuf->immutable)
return JS_ThrowTypeErrorImmutableArrayBuffer(ctx);
// Spec (ArrayBufferCopyAndDetach): the newLength argument must be
// coerced (its valueOf observed) before the buffer's detachability /
// immutability is checked, so side effects of coercion are visible.
if (argc < 1 || JS_IsUndefined(argv[0]))
new_len = abuf->byte_length;
else if (JS_ToIndex(ctx, &new_len, argv[0]))
return JS_EXCEPTION;
if (magic != JS_ARRAY_BUFFER_TRANSFER_TO_IMMUTABLE && abuf->immutable)
if (abuf->immutable)
return JS_ThrowTypeErrorImmutableArrayBuffer(ctx);
if (abuf->detached)
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
Expand Down Expand Up @@ -58350,10 +58351,17 @@ static JSValue js_array_buffer_slice(JSContext *ctx,
goto fail;
}
/* must test again because of side effects */
if (abuf->detached || abuf->byte_length < start + new_len) {
if (abuf->detached) {
JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
goto fail;
}
if (abuf->byte_length < start + new_len) {
if (immutable)
JS_ThrowRangeError(ctx, "invalid array buffer length");
else
JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
goto fail;
}
memcpy(new_abuf->data, abuf->data + start, new_len);
new_abuf->immutable = immutable;
return new_obj;
Expand Down
4 changes: 0 additions & 4 deletions test262_errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ test262/test/annexB/language/expressions/assignmenttargettype/callexpression-in-
test262/test/annexB/language/expressions/assignmenttargettype/callexpression-in-prefix-update.js:27: SyntaxError: invalid increment/decrement operand
test262/test/annexB/language/expressions/assignmenttargettype/callexpression.js:33: SyntaxError: invalid assignment left-hand side
test262/test/annexB/language/expressions/assignmenttargettype/cover-callexpression-and-asyncarrowhead.js:20: SyntaxError: invalid assignment left-hand side
test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-shrinks.js:40: Test262Error: resize below resolved end Expected a RangeError but got a TypeError
test262/test/built-ins/ArrayBuffer/prototype/sliceToImmutable/this-shrinks.js:40: strict mode: Test262Error: resize below resolved end Expected a RangeError but got a TypeError
test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-not-detachable.js:35: Test262Error: Actual [] and expected [newLength.valueOf] should have the same contents. [immutable ArrayBuffer] Must read arguments before verifying detachability.
test262/test/built-ins/ArrayBuffer/prototype/transferToImmutable/this-is-not-detachable.js:35: strict mode: Test262Error: Actual [] and expected [newLength.valueOf] should have the same contents. [immutable ArrayBuffer] Must read arguments before verifying detachability.
test262/test/built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-poisoned-wrapper.js:64: TypeError: $DONE() not called
test262/test/built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-poisoned-wrapper.js:64: strict mode: TypeError: $DONE() not called
test262/test/built-ins/AsyncFromSyncIteratorPrototype/next/next-result-poisoned-wrapper.js:69: TypeError: $DONE() not called
Expand Down