diff options
author | Matt Ranney <mjr@ranney.com> | 2010-06-24 12:26:23 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-06-25 09:10:49 -0700 |
commit | a2f70da4c9bf14a6e0c4a17cac11a5ab555ce90f (patch) | |
tree | 9bad42ebecbc06bdd1a5cbfe7f0ba9384a7adcb0 /lib/string_decoder.js | |
parent | aa491518f4632cd4c9d6a56382ee8395d42f3adc (diff) | |
download | node-a2f70da4c9bf14a6e0c4a17cac11a5ab555ce90f.tar.gz |
Buffer.copy should copy through sourceEnd, as specified.
Improve test-buffer.js to cover all copy error cases.
Fix off by one error in string_decoder.
Diffstat (limited to 'lib/string_decoder.js')
-rw-r--r-- | lib/string_decoder.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/string_decoder.js b/lib/string_decoder.js index 2c7ace0ae..7bae2fc47 100644 --- a/lib/string_decoder.js +++ b/lib/string_decoder.js @@ -25,7 +25,7 @@ StringDecoder.prototype.write = function (buffer) { : buffer.length; // add the new bytes to the char buffer - buffer.copy(this.charBuffer, this.charReceived, 0, i); + buffer.copy(this.charBuffer, this.charReceived, 0, (i - 1)); this.charReceived += i; if (this.charReceived < this.charLength) { @@ -79,7 +79,7 @@ StringDecoder.prototype.write = function (buffer) { } // buffer the incomplete character bytes we got - buffer.copy(this.charBuffer, 0, buffer.length - i, buffer.length); + buffer.copy(this.charBuffer, 0, buffer.length - i, (buffer.length - 1)); this.charReceived = i; if (buffer.length - i > 0) { |