Re: [whatwg/webidl] "byte length of a buffer source type" needs updating for resizable and detached buffers (Issue #1385)

Hm, actually, this is already an issue because of detached buffers. Reading the `[[ByteLength]]` slot of a (> 0 size) TypedArray which is backed by a detached ArrayBuffer will give you a positive integer, which means that the "byte length" will be a positive integer, which breaks at least `encodeInto`.

Consider writing the first byte into a Uint8Array backed by a detached buffer.
- "destination’s byte length − written is greater than or equal to the number of bytes in result" is false
- So we "[Write](https://webidl.spec.whatwg.org/#arraybufferview-write) the bytes in result into destination"
- which will "[Write](https://webidl.spec.whatwg.org/#arraybuffer-write) bytes into arrayBuffer with [startingOffset](https://webidl.spec.whatwg.org/#arraybuffer-write-startingoffset) set to jsView.[[ByteOffset]] + startingOffset."
- which asserts that "bytes’s length ≤ jsArrayBuffer.[[ArrayBufferByteLength]] − startingOffset."
- which assertion is violated: the [[ArrayBufferByteLength]] if a detached buffer [is zero](https://tc39.es/ecma262/multipage/structured-data.html#sec-detacharraybuffer).


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1385#issuecomment-1904500121
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1385/1904500121@github.com>

Received on Monday, 22 January 2024 17:43:56 UTC