From 8a6a6449f803f6ccc73be53b06c3b6f0df3a6727 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 13 Jun 2020 21:53:52 +0200 Subject: [PATCH] src: handle empty Maybe(Local) in node_util.cc PR-URL: https://github.com/nodejs/node/pull/33867 Refs: https://github.com/nodejs/node/blob/master/src/README.md#checked-conversion Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- src/node_util.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/node_util.cc b/src/node_util.cc index 199b04c95b44d4..22a372ad09a3bd 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -148,11 +148,11 @@ static void GetHiddenValue(const FunctionCallbackInfo& args) { CHECK(args[1]->IsUint32()); Local obj = args[0].As(); - auto index = args[1]->Uint32Value(env->context()).FromJust(); - auto private_symbol = IndexToPrivateSymbol(env, index); - auto maybe_value = obj->GetPrivate(env->context(), private_symbol); - - args.GetReturnValue().Set(maybe_value.ToLocalChecked()); + uint32_t index = args[1].As()->Value(); + Local private_symbol = IndexToPrivateSymbol(env, index); + Local ret; + if (obj->GetPrivate(env->context(), private_symbol).ToLocal(&ret)) + args.GetReturnValue().Set(ret); } static void SetHiddenValue(const FunctionCallbackInfo& args) { @@ -162,11 +162,11 @@ static void SetHiddenValue(const FunctionCallbackInfo& args) { CHECK(args[1]->IsUint32()); Local obj = args[0].As(); - auto index = args[1]->Uint32Value(env->context()).FromJust(); - auto private_symbol = IndexToPrivateSymbol(env, index); - auto maybe_value = obj->SetPrivate(env->context(), private_symbol, args[2]); - - args.GetReturnValue().Set(maybe_value.FromJust()); + uint32_t index = args[1].As()->Value(); + Local private_symbol = IndexToPrivateSymbol(env, index); + bool ret; + if (obj->SetPrivate(env->context(), private_symbol, args[2]).To(&ret)) + args.GetReturnValue().Set(ret); } static void Sleep(const FunctionCallbackInfo& args) {