From b64a521d665608379429614f5b337b8c6323233a Mon Sep 17 00:00:00 2001 From: Peter Griess Date: Wed, 14 Jul 2010 18:07:17 -0500 Subject: [PATCH] Buffer('') should create a 0-length buffer --- src/node_buffer.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 7d7e35540..8d35b7e6d 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -352,7 +352,7 @@ Handle Buffer::Utf8Write(const Arguments &args) { size_t offset = args[1]->Int32Value(); - if (offset >= buffer->length_) { + if (s->Utf8Length() > 0 && offset >= buffer->length_) { return ThrowException(Exception::TypeError(String::New( "Offset is out of bounds"))); } @@ -390,7 +390,7 @@ Handle Buffer::AsciiWrite(const Arguments &args) { size_t offset = args[1]->Int32Value(); - if (offset >= buffer->length_) { + if (s->Length() > 0 && offset >= buffer->length_) { return ThrowException(Exception::TypeError(String::New( "Offset is out of bounds"))); } @@ -418,7 +418,7 @@ Handle Buffer::BinaryWrite(const Arguments &args) { size_t offset = args[1]->Int32Value(); - if (offset >= buffer->length_) { + if (s->Length() > 0 && offset >= buffer->length_) { return ThrowException(Exception::TypeError(String::New( "Offset is out of bounds"))); } -- 2.34.1