Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

buffer: use NO_NULL_TERMINATION flag

Refs #394.
  • Loading branch information...
commit ab29da129f7474838c3e0f90d010eb260f9d9809 1 parent d2698d1
@koichik authored
Showing with 6 additions and 11 deletions.
  1. +6 −11 src/node_buffer.cc
View
17 src/node_buffer.cc
@@ -493,19 +493,12 @@ Handle<Value> Buffer::Utf8Write(const Arguments &args) {
int written = s->WriteUtf8(p,
max_length,
&char_written,
- String::HINT_MANY_WRITES_EXPECTED);
+ (String::HINT_MANY_WRITES_EXPECTED |
+ String::NO_NULL_TERMINATION));
constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(char_written));
- if (written > 0 && p[written-1] == '\0' && char_written == length) {
- uint16_t last_char;
- s->Write(&last_char, length - 1, 1, String::NO_OPTIONS);
- if (last_char != 0 || written > s->Utf8Length()) {
- written--;
- }
- }
-
return scope.Close(Integer::New(written));
}
@@ -538,7 +531,8 @@ Handle<Value> Buffer::Ucs2Write(const Arguments &args) {
int written = s->Write(p,
0,
max_length,
- String::HINT_MANY_WRITES_EXPECTED);
+ (String::HINT_MANY_WRITES_EXPECTED |
+ String::NO_NULL_TERMINATION));
constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(written));
@@ -576,7 +570,8 @@ Handle<Value> Buffer::AsciiWrite(const Arguments &args) {
int written = s->WriteAscii(p,
0,
max_length,
- String::HINT_MANY_WRITES_EXPECTED);
+ (String::HINT_MANY_WRITES_EXPECTED |
+ String::NO_NULL_TERMINATION));
constructor_template->GetFunction()->Set(chars_written_sym,
Integer::New(written));
Please sign in to comment.
Something went wrong with that request. Please try again.