Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-08-26 11:30:32 +0300
committerMichaël Zasso <targos@protonmail.com>2018-08-29 13:28:19 +0300
commitb2f0cfa6b0e139a2f990d4e1e7104abf015fe8e7 (patch)
treee3e86531acf52d314d21ffb24f5bc0d55589fd7e /src/node_buffer.cc
parent17dd620e58f32f2e44b12b139b76f6c3d7abae75 (diff)
src: use String::Utf8Length with isolate
PR-URL: https://github.com/nodejs/node/pull/22531 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r--src/node_buffer.cc7
1 files changed, 4 insertions, 3 deletions
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<Value>& 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<Value>& args) {
}
void ByteLengthUtf8(const FunctionCallbackInfo<Value> &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<String>()->Utf8Length());
+ args.GetReturnValue().Set(args[0].As<String>()->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<Value>& args) {
CHECK(args[0]->IsString());
Local<String> str = args[0].As<String>();
- size_t length = str->Utf8Length();
+ size_t length = str->Utf8Length(isolate);
char* data = node::UncheckedMalloc(length);
str->WriteUtf8(isolate,
data,