archives

« Bugzilla Issues Index

#1565 — ArrayBuffer, TypedArray and DataView constructors should throw RangeError if byteLength parameter is negative


Current specification suggests that negative byteLengths are clamped to 0.
This is counter-intuitive, leads to sloppy code and incompatible with existing implementations in chromium, safari and firefox.


Can you be more specific about where you see this issue (other than in DataView which still needs to be redone). The following places in rev 15 all check and throw if the length is < 0:

step 8 of 15.13.5.12.1 ArrayBuffer(length)
step 10 of 15.13.6.1.1 TypedArray(length)
step 12 of 15.13.6.1.3 TypedArray(array)
step 13.d of 15.136.1.4 TypedArray(buffer, byteOffset, length)


You(In reply to comment #1)
> Can you be more specific about where you see this issue (other than in DataView
> which still needs to be redone). The following places in rev 15 all check and
> throw if the length is < 0:
>
> step 8 of 15.13.5.12.1 ArrayBuffer(length)
> step 10 of 15.13.6.1.1 TypedArray(length)
> step 12 of 15.13.6.1.3 TypedArray(array)
> step 13.d of 15.136.1.4 TypedArray(buffer, byteOffset, length)

You are right; I guess I was looking at rev 14.
Sorry for the noise!