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 <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and codebytere committed Jun 30, 2020
1 parent a4c63c7 commit 8a6a644
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 8a6a644

Please sign in to comment.