diff --git a/benchmark/napi/function_args/binding.cc b/benchmark/napi/function_args/binding.cc index 2c8fc7231f8..d0c1a079210 100644 --- a/benchmark/napi/function_args/binding.cc +++ b/benchmark/napi/function_args/binding.cc @@ -19,7 +19,7 @@ void CallWithString(const FunctionCallbackInfo& args) { assert(args.Length() == 1 && args[0]->IsString()); if (args.Length() == 1 && args[0]->IsString()) { Local str = args[0].As(); - const int32_t length = str->Utf8Length() + 1; + const int32_t length = str->Utf8Length(args.GetIsolate()) + 1; char* buf = new char[length]; str->WriteUtf8(args.GetIsolate(), buf, length); delete [] buf; diff --git a/src/node_api.cc b/src/node_api.cc index 8ccadab3061..727ca0cf702 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -2399,7 +2399,7 @@ napi_status napi_get_value_string_utf8(napi_env env, if (!buf) { CHECK_ARG(env, result); - *result = val.As()->Utf8Length(); + *result = val.As()->Utf8Length(env->isolate); } else { int copied = val.As()->WriteUtf8( env->isolate, diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 95ffaa1993f..9a280f7c127 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -599,7 +599,7 @@ void Fill(const FunctionCallbackInfo& args) { // Can't use StringBytes::Write() in all cases. For example if attempting // to write a two byte character into a one byte Buffer. if (enc == UTF8) { - str_length = str_obj->Utf8Length(); + str_length = str_obj->Utf8Length(env->isolate()); node::Utf8Value str(env->isolate(), args[1]); memcpy(ts_obj_data + start, *str, MIN(str_length, fill_length)); @@ -689,10 +689,11 @@ void StringWrite(const FunctionCallbackInfo& args) { } void ByteLengthUtf8(const FunctionCallbackInfo &args) { + Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsString()); // Fast case: avoid StringBytes on UTF8 string. Jump to v8. - args.GetReturnValue().Set(args[0].As()->Utf8Length()); + args.GetReturnValue().Set(args[0].As()->Utf8Length(env->isolate())); } // Normalize val to be an integer in the range of [1, -1] since @@ -1062,7 +1063,7 @@ static void EncodeUtf8String(const FunctionCallbackInfo& args) { CHECK(args[0]->IsString()); Local str = args[0].As(); - size_t length = str->Utf8Length(); + size_t length = str->Utf8Length(isolate); char* data = node::UncheckedMalloc(length); str->WriteUtf8(isolate, data, diff --git a/src/string_bytes.cc b/src/string_bytes.cc index c106571a468..b7f009fe1fc 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -465,7 +465,7 @@ size_t StringBytes::Size(Isolate* isolate, case BUFFER: case UTF8: - return str->Utf8Length(); + return str->Utf8Length(isolate); case UCS2: return str->Length() * sizeof(uint16_t);