diff --git a/src/node_buffer.cc b/src/node_buffer.cc index b7c5d859ad..8b48f2a2e6 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -232,8 +232,7 @@ Handle Buffer::AsciiSlice(const Arguments &args) { SLICE_ARGS(args[0], args[1]) char* data = parent->data_ + start; - size_t len = strnlen(data, end - start); - Local string = String::New(data, len); + Local string = String::New(data, end - start); return scope.Close(string); } @@ -243,13 +242,11 @@ Handle Buffer::Utf8Slice(const Arguments &args) { HandleScope scope; Buffer *parent = ObjectWrap::Unwrap(args.This()); SLICE_ARGS(args[0], args[1]) - char* data = parent->data_ + start; - size_t len = strnlen(data, end - start); - Local string = String::New(data, len); + char *data = parent->data_ + start; + Local string = String::New(data, end - start); return scope.Close(string); } - Handle Buffer::Ucs2Slice(const Arguments &args) { HandleScope scope; Buffer *parent = ObjectWrap::Unwrap(args.This()); @@ -259,7 +256,6 @@ Handle Buffer::Ucs2Slice(const Arguments &args) { return scope.Close(string); } - static const char *base64_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index 5db92283f4..0aad8149f7 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -410,15 +410,3 @@ assert.equal(12, Buffer.byteLength('Il était tué', 'binary')); // slice(0,0).length === 0 assert.equal(0, Buffer('hello').slice(0, 0).length); - - -// toString('utf8') should not include null values -var b = new Buffer(20); -for (var i = 0; i < b.length; i++) { - b[i] = 0; -} -b.write('hello'); -assert.equal('hello', b.toString('utf8')); -assert.equal('hello', b.toString('ascii')); - -