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

DataView is not checking non-auto resizable ArrayBuffer's length #106

Closed
Constellation opened this issue Nov 15, 2022 · 1 comment · Fixed by #109
Closed

DataView is not checking non-auto resizable ArrayBuffer's length #106

Constellation opened this issue Nov 15, 2022 · 1 comment · Fixed by #109

Comments

@Constellation
Copy link
Member

Since https://tc39.es/proposal-resizablearraybuffer/#sec-getviewbytelength is always returning the specified length if the length is not auto, IsViewOutOfBounds passes without consulting to the underlying ArrayBuffer.

  1. If view.[[ByteLength]] is not auto, then return view.[[ByteLength]].

So, I think the following code crashes, is it correct?

var buffer = new ArrayBuffer(1024, { maxByteLength: 2048 });
// not auto, 16 byteLength DataView
var view = new DataView(buffer, 0, 16);
buffer.resize(0);
// Now, underlying buffer's byteLength becomes 0, but IsViewOutOfBounds passes.
view.setUint16(0, 32);
@syg
Copy link
Collaborator

syg commented Nov 15, 2022

Thanks for pointing this out, this is a bug in the DataView sections. The DataView stuff is kind of rough, sorry about that.

syg added a commit that referenced this issue Nov 17, 2022
syg added a commit that referenced this issue Dec 3, 2022
@syg syg closed this as completed in #109 Dec 3, 2022
syg added a commit that referenced this issue Dec 3, 2022
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 a pull request may close this issue.

2 participants