diff --git a/src/util.cc b/src/util.cc index 91c69a98c49c41..f28f906b4b7b6b 100644 --- a/src/util.cc +++ b/src/util.cc @@ -358,7 +358,7 @@ Local NewFunctionTemplate( void SetMethod(Local context, Local that, - const char* name, + const std::string_view name, v8::FunctionCallback callback) { Isolate* isolate = context->GetIsolate(); Local function = @@ -372,14 +372,15 @@ void SetMethod(Local context, // kInternalized strings are created in the old space. const v8::NewStringType type = v8::NewStringType::kInternalized; Local name_string = - v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked(); + v8::String::NewFromUtf8(isolate, name.data(), type, name.size()) + .ToLocalChecked(); that->Set(context, name_string, function).Check(); function->SetName(name_string); // NODE_SET_METHOD() compatibility. } void SetMethod(v8::Isolate* isolate, v8::Local that, - const char* name, + const std::string_view name, v8::FunctionCallback callback) { Local t = NewFunctionTemplate(isolate, @@ -390,13 +391,14 @@ void SetMethod(v8::Isolate* isolate, // kInternalized strings are created in the old space. const v8::NewStringType type = v8::NewStringType::kInternalized; Local name_string = - v8::String::NewFromUtf8(isolate, name, type).ToLocalChecked(); + v8::String::NewFromUtf8(isolate, name.data(), type, name.size()) + .ToLocalChecked(); that->Set(name_string, t); } void SetFastMethod(Isolate* isolate, Local