diff --git a/src/util.cc b/src/util.cc index 1512f262fd9..78326b56eab 100644 --- a/src/util.cc +++ b/src/util.cc @@ -146,12 +146,10 @@ TwoByteValue::TwoByteValue(Isolate* isolate, Local value) { Local 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); }