@@ -111,9 +111,10 @@ static void SafeGetenv(const FunctionCallbackInfo<Value>& args) {
111111 Utf8Value strenvtag (isolate, args[0 ]);
112112 std::string text;
113113 if (!SafeGetenv (*strenvtag, &text, env)) return ;
114- Local<Value> result =
115- ToV8Value (isolate->GetCurrentContext (), text).ToLocalChecked ();
116- args.GetReturnValue ().Set (result);
114+ Local<Value> result;
115+ if (ToV8Value (isolate->GetCurrentContext (), text).ToLocal (&result)) {
116+ args.GetReturnValue ().Set (result);
117+ }
117118}
118119
119120static void GetTempDir (const FunctionCallbackInfo<Value>& args) {
@@ -137,8 +138,10 @@ static void GetTempDir(const FunctionCallbackInfo<Value>& args) {
137138 dir.pop_back ();
138139 }
139140
140- args.GetReturnValue ().Set (
141- ToV8Value (isolate->GetCurrentContext (), dir).ToLocalChecked ());
141+ Local<Value> result;
142+ if (ToV8Value (isolate->GetCurrentContext (), dir).ToLocal (&result)) {
143+ args.GetReturnValue ().Set (result);
144+ }
142145}
143146
144147#ifdef NODE_IMPLEMENTS_POSIX_CREDENTIALS
@@ -385,9 +388,10 @@ static void GetGroups(const FunctionCallbackInfo<Value>& args) {
385388 gid_t egid = getegid ();
386389 if (std::find (groups.begin (), groups.end (), egid) == groups.end ())
387390 groups.push_back (egid);
388- MaybeLocal<Value> array = ToV8Value (env->context (), groups);
389- if (!array.IsEmpty ())
390- args.GetReturnValue ().Set (array.ToLocalChecked ());
391+ Local<Value> result;
392+ if (ToV8Value (env->context (), groups).ToLocal (&result)) {
393+ args.GetReturnValue ().Set (result);
394+ }
391395}
392396
393397static void SetGroups (const FunctionCallbackInfo<Value>& args) {
@@ -403,8 +407,12 @@ static void SetGroups(const FunctionCallbackInfo<Value>& args) {
403407 MaybeStackBuffer<gid_t , 64 > groups (size);
404408
405409 for (size_t i = 0 ; i < size; i++) {
406- gid_t gid = gid_by_name (
407- env->isolate (), groups_list->Get (env->context (), i).ToLocalChecked ());
410+ Local<Value> val;
411+ if (!groups_list->Get (env->context (), i).ToLocal (&val)) {
412+ // V8 will have scheduled an error to be thrown.
413+ return ;
414+ }
415+ gid_t gid = gid_by_name (env->isolate (), val);
408416
409417 if (gid == gid_not_found) {
410418 // Tells JS to throw ERR_INVALID_CREDENTIAL
0 commit comments