From 2e371b8f926a6a0ae07a18c61c773dbd8cef7aeb Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 27 Jan 2013 21:50:00 +0100 Subject: [PATCH] buffer: fix Buffer::Copy regression from 00b4b7b If the end argument is omitted or not a number, make it default to the end of the buffer, not zero. Ideally, it should not matter what it defaults to because the JS shim in lib/buffer.js should handle that but there are still several places in node.js core that secrete SlowBuffers, hence Buffer::Copy() gets called without going through Buffer.prototype.copy() first. --- src/node_buffer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 2fa7e89952..167bbdead6 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -403,7 +403,8 @@ Handle Buffer::Copy(const Arguments &args) { size_t target_length = Buffer::Length(target); size_t target_start = args[1]->Uint32Value(); size_t source_start = args[2]->Uint32Value(); - size_t source_end = args[3]->Uint32Value(); + size_t source_end = args[3]->IsUint32() ? args[3]->Uint32Value() + : source->length_; if (source_end < source_start) { return ThrowRangeError("sourceEnd < sourceStart");