buffer-browserify icon indicating copy to clipboard operation
buffer-browserify copied to clipboard

buf[i] not working sometimes

Open andrewrk opened this issue 11 years ago • 4 comments

Causing zlib-browserify to be broken: https://github.com/brianloveswords/zlib-browserify/issues/6

To produce the issue:

  1. Clone this gist
  2. browserify test.js >out.js
  3. Copy out.js into jsbeautifier.org and then paste back into out.js
  4. Add a debugger statement like this:
                        debugger
                        a.C = l[k++];
                        a.D = l[k++];
                        (31 !== a.C || 139 !== a.D) && m(Error("invalid file signature:", a.C, a.D));
  1. run in the browser

You will notice that l is a Buffer and l[0] is yielding undefined when it should yield 31. Note also that l.parent[0] works.

andrewrk avatar Aug 08 '13 19:08 andrewrk

@substack might be interested to see this.

andrewrk avatar Aug 08 '13 19:08 andrewrk

I've found that an implementation of a streaming Boyer-Moore-Horspool search streamsearch breaks because of this. Seems pretty egregious as it's a break from the Node API.

terinjokes avatar Sep 18 '13 23:09 terinjokes

@terinjokes for what it's worth, I think I got around the issue by using https://github.com/chrisdickinson/bops

but even then there was an issue I had to work around: https://github.com/chrisdickinson/bops/pull/7

andrewrk avatar Sep 18 '13 23:09 andrewrk

This actually looks fixed in HEAD, but hasn't been pulled into a newer version of insert-module-globals.

terinjokes avatar Sep 19 '13 00:09 terinjokes