Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,10 @@ TwoByteValue::TwoByteValue(Isolate* isolate, Local<Value> value) {
Local<String> string;
if (!value->ToString(isolate->GetCurrentContext()).ToLocal(&string)) return;

// Allocate enough space to include the null terminator
const size_t storage = string->Length() + 1;
AllocateSufficientStorage(storage);

const int flags = String::NO_NULL_TERMINATION;
const int length = string->Write(isolate, out(), 0, storage, flags);
// Allocate enough space to include the null terminator.
const size_t length = string->Length();
AllocateSufficientStorage(length + 1);
string->WriteV2(isolate, 0, length, out());
SetLengthAndZeroTerminate(length);
}

Expand Down
Loading