Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
buffer: Fix Buffer.copy() third arg default
Browse files Browse the repository at this point in the history
Third argument should default to source.length, not 0.

Broken in 00b4b7b.
  "buffer: remove minor Buffer::Copy deoptimizations"
  • Loading branch information
isaacs committed Jan 27, 2013
1 parent 0972acb commit f0bad5a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/node_buffer.cc
Expand Up @@ -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]->IsUndefined() ? source->length_
: args[3]->Uint32Value();

if (source_end < source_start) {
return ThrowRangeError("sourceEnd < sourceStart");
Expand Down

0 comments on commit f0bad5a

Please sign in to comment.