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

Commit

Permalink
Check buffer length using string length
Browse files Browse the repository at this point in the history
   + Utf8Length is really slow but has the same semantics in this case
  • Loading branch information
brapse authored and ry committed Dec 3, 2010
1 parent c70acbb commit fcc3812
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Handle<Value> Buffer::Copy(const Arguments &args) {
ssize_t to_copy = MIN(MIN(source_end - source_start,
target_length - target_start),
source->length_ - source_start);


// need to use slightly slower memmove is the ranges might overlap
memmove((void *)(target_data + target_start),
Expand All @@ -406,7 +406,7 @@ Handle<Value> Buffer::Utf8Write(const Arguments &args) {

size_t offset = args[1]->Uint32Value();

if (s->Utf8Length() > 0 && offset >= buffer->length_) {
if (s->Length() > 0 && offset >= buffer->length_) {
return ThrowException(Exception::TypeError(String::New(
"Offset is out of bounds")));
}
Expand Down

0 comments on commit fcc3812

Please sign in to comment.