toots / buffer-browserify

node's buffer module, but for the browser.
MIT License
52 stars 33 forks source link

Fix overflow issues on writing/reading integers #11

Closed tonistiigi closed 11 years ago

tonistiigi commented 11 years ago

buffer-browserify does not handle writing and reading out of bounds correctly.

This PR only fixes Integers. Floats probably have same issues.

toots commented 11 years ago

Hi and thanks for you work!

Is the overflow present in node's original module? Even though it is a bug, I want to stick to node's implementation as much as possible so that there's no surprise when running code on browserify that has been written for node..

tonistiigi commented 11 years ago

Yes, this is the way node handles overflow. I also added a testcase that compares results from node to this module.

The implementation is different because in node its based on fixed length typed-array and there is no way to write over the length of the buffer. In buffer-browserify it just directly accesses slowbuffer and length has no special meaning.

toots commented 11 years ago

Oh, my bad I did not see the test. Merging, thanks!