diff --git a/src/string_bytes.cc b/src/string_bytes.cc index 4a91f25048..1f5e592a32 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -263,7 +263,7 @@ bool StringBytes::GetExternalParts(Isolate* isolate, const String::ExternalStringResource* ext; ext = str->GetExternalStringResource(); *data = reinterpret_cast(ext->data()); - *len = ext->length(); + *len = ext->length() * sizeof(*ext->data()); return true; } @@ -317,7 +317,7 @@ size_t StringBytes::Write(Isolate* isolate, case UCS2: if (is_extern) - memcpy(buf, data, len * 2); + memcpy(buf, data, len); else len = str->Write(reinterpret_cast(buf), 0, buflen, flags); if (IsBigEndian()) {