diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 1e966e42c68ce6..ba29aaeef03618 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -981,7 +981,8 @@ int SyncProcessRunner::CopyJsString(Local js_value, if (js_value->IsString()) js_string = js_value.As(); else - js_string = js_value->ToString(env()->isolate()); + js_string = js_value->ToString(env()->isolate()->GetCurrentContext()) + .ToLocalChecked(); // Include space for null terminator byte. size = StringBytes::StorageSize(isolate, js_string, UTF8) + 1; @@ -1025,7 +1026,12 @@ int SyncProcessRunner::CopyJsStringArray(Local js_value, auto value = js_array->Get(context, i).ToLocalChecked(); if (!value->IsString()) - js_array->Set(context, i, value->ToString(env()->isolate())).FromJust(); + js_array + ->Set(context, + i, + value->ToString(env()->isolate()->GetCurrentContext()) + .ToLocalChecked()) + .FromJust(); data_size += StringBytes::StorageSize(isolate, value, UTF8) + 1; data_size = ROUND_UP(data_size, sizeof(void*)); diff --git a/src/string_bytes.cc b/src/string_bytes.cc index b7f009fe1fcc16..82d699db9a81e5 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -410,7 +410,8 @@ size_t StringBytes::StorageSize(Isolate* isolate, return Buffer::Length(val); } - Local str = val->ToString(isolate); + Local str = + val->ToString(isolate->GetCurrentContext()).ToLocalChecked(); switch (encoding) { case ASCII: @@ -456,7 +457,8 @@ size_t StringBytes::Size(Isolate* isolate, if (Buffer::HasInstance(val) && (encoding == BUFFER || encoding == LATIN1)) return Buffer::Length(val); - Local str = val->ToString(isolate); + Local str = + val->ToString(isolate->GetCurrentContext()).ToLocalChecked(); switch (encoding) { case ASCII: diff --git a/src/util.cc b/src/util.cc index c36ea5169d3313..44c47f0f9163dc 100644 --- a/src/util.cc +++ b/src/util.cc @@ -37,9 +37,8 @@ template static void MakeUtf8String(Isolate* isolate, Local value, T* target) { - Local string = value->ToString(isolate); - if (string.IsEmpty()) - return; + Local string; + if (!value->ToString(isolate->GetCurrentContext()).ToLocal(&string)) return; const size_t storage = StringBytes::StorageSize(isolate, string, UTF8) + 1; target->AllocateSufficientStorage(storage); @@ -63,9 +62,8 @@ TwoByteValue::TwoByteValue(Isolate* isolate, Local value) { return; } - Local string = value->ToString(isolate); - if (string.IsEmpty()) - return; + Local string; + if (!value->ToString(isolate->GetCurrentContext()).ToLocal(&string)) return; // Allocate enough space to include the null terminator const size_t storage = string->Length() + 1;