Skip to content

Commit

Permalink
src: handle empty Maybe(Local) in node_util.cc
Browse files Browse the repository at this point in the history
PR-URL: #33867
Refs: https://github.com/nodejs/node/blob/master/src/README.md#checked-conversion
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax authored and codebytere committed Jun 27, 2020
1 parent 0a7f13e commit 9a52cd9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/node_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ static void GetHiddenValue(const FunctionCallbackInfo<Value>& args) {
CHECK(args[1]->IsUint32());

Local<Object> obj = args[0].As<Object>();
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<Uint32>()->Value();
Local<Private> private_symbol = IndexToPrivateSymbol(env, index);
Local<Value> ret;
if (obj->GetPrivate(env->context(), private_symbol).ToLocal(&ret))
args.GetReturnValue().Set(ret);
}

static void SetHiddenValue(const FunctionCallbackInfo<Value>& args) {
Expand All @@ -162,11 +162,11 @@ static void SetHiddenValue(const FunctionCallbackInfo<Value>& args) {
CHECK(args[1]->IsUint32());

Local<Object> obj = args[0].As<Object>();
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<Uint32>()->Value();
Local<Private> 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<Value>& args) {
Expand Down

0 comments on commit 9a52cd9

Please sign in to comment.