Fix detach check in ArrayBuffer.prototype.resize (#681)

This commit is contained in:
Ben Noordhuis 2024-11-13 16:04:49 +01:00 committed by GitHub
parent fa4d2454aa
commit 1cc19e4dbf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 4 deletions

View file

@ -51982,6 +51982,8 @@ static JSValue js_array_buffer_resize(JSContext *ctx, JSValue this_val,
abuf = JS_GetOpaque2(ctx, this_val, class_id);
if (!abuf)
return JS_EXCEPTION;
if (JS_ToInt64(ctx, &len, argv[0]))
return JS_EXCEPTION;
if (abuf->detached)
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
if (!array_buffer_is_resizable(abuf))
@ -51989,8 +51991,6 @@ static JSValue js_array_buffer_resize(JSContext *ctx, JSValue this_val,
// TODO(bnoordhuis) support externally managed RABs
if (abuf->free_func != js_array_buffer_free)
return JS_ThrowTypeError(ctx, "external array buffer is not resizable");
if (JS_ToInt64(ctx, &len, argv[0]))
return JS_EXCEPTION;
if (len < 0 || len > abuf->max_byte_length) {
bad_length:
return JS_ThrowRangeError(ctx, "invalid array buffer length");

View file

@ -1,5 +1,3 @@
test262/test/built-ins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js:15: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
test262/test/built-ins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js:15: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
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