Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Normative: Check for detached buffers before calling HostResizeArrayBuffer #123

Closed
wants to merge 1 commit into from

Conversation

anba
Copy link
Contributor

@anba anba commented Jul 3, 2023

ToIntegerOrInfinity can detach the buffer, adding an explicit IsDetachedBuffer call makes it more clear which error should be thrown in that case.

…uffer

`ToIntegerOrInfinity` can detach the buffer, adding an explicit
`IsDetachedBuffer` call makes it more clear which error should be
thrown in that case.
@anba
Copy link
Contributor Author

anba commented Jul 3, 2023

This test throws a TypeError in V8, but a RangeError in JSC:

let buffer = new ArrayBuffer(4, {maxByteLength: 8});
buffer.resize({
  valueOf() {
    buffer.transfer();
    return 4;
  }
});

With the proposed change, a TypeError is expected.

@@ -276,6 +276,7 @@ <h1>ArrayBuffer.prototype.resize ( _newLength_ )</h1>
1. If IsDetachedBuffer(_O_) is *true*, throw a *TypeError* exception.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. If IsDetachedBuffer(_O_) is *true*, throw a *TypeError* exception.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, given lack of interop right now between V8 and JSC, I'd prefer to sink the detached check to be after the _newLength_ coercion. I'll add it to the agenda.

@syg
Copy link
Collaborator

syg commented Jul 7, 2023

Oh actually this is just duplicated of #120.

@syg syg closed this Jul 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants