Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer.slice is broken for Windows Edge users and in Firefox developer edition #120

Closed
jcalfee opened this issue Jun 15, 2016 · 5 comments
Closed

Comments

@jcalfee
Copy link

jcalfee commented Jun 15, 2016

We noticed that some Windows Edge users and in the latest developer edition of Firefox (v49) Buffer slice is failing. We successfully worked around the problem by setting TYPED_ARRAY_SUPPORT = false. The issue happens when this.subarray(start, end) returns the wrong results. You can see the problem with this test: new Buffer("abc").slice(0, 2) === "abc" .. This will return true if you have the bug.

I believe this.subarray is native so I have also reported this issue here: https://bugzilla.mozilla.org/show_bug.cgi?id=1280052

Buffer.prototype.slice = function slice (start, end) {
...
 var newBuf
  if (Buffer.TYPED_ARRAY_SUPPORT) {
    newBuf = Buffer._augment(this.subarray(start, end))
  } else {
    var sliceLen = end - start
    newBuf = new Buffer(sliceLen, undefined)
    for (var i = 0; i < sliceLen; i++) {
      newBuf[i] = this[i + start]
    }
  }
...
@feross
Copy link
Owner

feross commented Jun 15, 2016

It looks like you're using an old version of this library. You can use npm ls buffer to see which packages are depending on buffer. The current version of buffer is 4.6.0.

@feross feross closed this as completed Jun 15, 2016
@feross
Copy link
Owner

feross commented Jun 15, 2016

This issue is fixed in the latest version of buffer.

@nolanlawson
Copy link
Collaborator

By any chance was an issue filed on Edge as well? We care a lot about library compat and want to make sure we don't break the ecosystem.

Here's our issue tracker. A complete Gist to reproduce would be really helpful (or at least which version of buffer you're using so that we can reproduce).

@feross
Copy link
Owner

feross commented Jun 16, 2016

@nolanlawson This issue was fixed by #97 a while ago.

@nolanlawson
Copy link
Collaborator

Ah OK, got it. I'll add a comment to the Mozilla bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants