DataView.prototype.byteLength and byteOffset should throw when the underlying buffer is detached

RESOLVED FIXED in Firefox 57

Status

()

defect
RESOLVED FIXED
3 years ago
2 years ago

People

(Reporter: anba, Assigned: evilpie)

Tracking

(Blocks 1 bug)

Trunk
mozilla57
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox53 affected, firefox57 fixed)

Details

Attachments

(1 attachment)

Reporter

Description

3 years ago
Test case:
---
var ab = new ArrayBuffer(10);
var dv = new DataView(ab)
detachArrayBuffer(ab);
dv.byteLength; // Or: dv.byteOffset;
---

Expected: Throws TypeError
Actual: No exception thrown


Also see bug 1079853.
Assignee

Comment 1

2 years ago
Somehow I never uploaded this patch, but I think there is nothing wrong with it.
Assignee: nobody → evilpies
Attachment #8906269 - Flags: review?(andrebargull)
Reporter

Updated

2 years ago
Attachment #8906269 - Attachment is patch: true
Reporter

Comment 2

2 years ago
Comment on attachment 8906269 [details] [diff] [review]
Throw on detached ArrayBuffer in DataView getters

Review of attachment 8906269 [details] [diff] [review]:
-----------------------------------------------------------------

Nothing wrong with the patch itself, but I'm wondering about web-compatibility. AFAICS, no other browser is currently throwing a TypeError for detached buffers in the byteLength and byteOffset getters. Do you think it's still okay to let this change ride the trains to release, or is it more safe to restrict it to nightly+beta for a longer time until we're sure it won't break web-sites?
Attachment #8906269 - Flags: review?(andrebargull) → review+
Assignee

Comment 3

2 years ago
Oh, maybe that's why I never bothered with this. My feeling tells me DataView aren't actually used much and detached array buffers are probably also not that common. Making it Nightly only at least for the 57 cycle sounds like a good idea anyway.

Comment 4

2 years ago
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a31657380189
Make DataView getters throw for detached array buffers in Nightly. r=anba
Assignee

Updated

2 years ago
Blocks: 1398839

Comment 5

2 years ago
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b7f103d256b9
Fix bustage on CLOSED TREE by changing an old test.

Comment 6

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/a31657380189
https://hg.mozilla.org/mozilla-central/rev/b7f103d256b9
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.