diff --git a/src/util.cc b/src/util.cc index 3b0278cedaff67..20325d0bedbeb4 100644 --- a/src/util.cc +++ b/src/util.cc @@ -47,7 +47,9 @@ TwoByteValue::TwoByteValue(Isolate* isolate, Local value) return; // Allocate enough space to include the null terminator - size_t len = StringBytes::StorageSize(isolate, string, UCS2) + 1; + size_t len = + StringBytes::StorageSize(isolate, string, UCS2) + + sizeof(uint16_t); if (len > sizeof(str_st_)) { str_ = static_cast(malloc(len)); CHECK_NE(str_, nullptr);