Skip to content

Commit 1cc19e4

Browse files
authored
Fix detach check in ArrayBuffer.prototype.resize (#681)
1 parent fa4d245 commit 1cc19e4

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

quickjs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51982,15 +51982,15 @@ static JSValue js_array_buffer_resize(JSContext *ctx, JSValue this_val,
5198251982
abuf = JS_GetOpaque2(ctx, this_val, class_id);
5198351983
if (!abuf)
5198451984
return JS_EXCEPTION;
51985+
if (JS_ToInt64(ctx, &len, argv[0]))
51986+
return JS_EXCEPTION;
5198551987
if (abuf->detached)
5198651988
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
5198751989
if (!array_buffer_is_resizable(abuf))
5198851990
return JS_ThrowTypeError(ctx, "array buffer is not resizable");
5198951991
// TODO(bnoordhuis) support externally managed RABs
5199051992
if (abuf->free_func != js_array_buffer_free)
5199151993
return JS_ThrowTypeError(ctx, "external array buffer is not resizable");
51992-
if (JS_ToInt64(ctx, &len, argv[0]))
51993-
return JS_EXCEPTION;
5199451994
if (len < 0 || len > abuf->max_byte_length) {
5199551995
bad_length:
5199651996
return JS_ThrowRangeError(ctx, "invalid array buffer length");

test262_errors.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
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
2-
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
31
test262/test/built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-poisoned-wrapper.js:64: TypeError: $DONE() not called
42
test262/test/built-ins/AsyncFromSyncIteratorPrototype/next/iterator-result-poisoned-wrapper.js:64: strict mode: TypeError: $DONE() not called
53
test262/test/built-ins/AsyncFromSyncIteratorPrototype/next/next-result-poisoned-wrapper.js:69: TypeError: $DONE() not called

0 commit comments

Comments
 (0)