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.
This commit is contained in:
parent
0972acb548
commit
2e371b8f92
@ -403,7 +403,8 @@ Handle<Value> 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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user