From 3d90825037ddeedd90b4f36c4f9054ec78d7931f Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 13 Jun 2020 21:53:52 +0200 Subject: [PATCH 1/3] src: handle empty Maybe(Local) in node_util.cc --- src/node_util.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/node_util.cc b/src/node_util.cc index ec3f8e1fe7deaf..0b743f2f5c04a5 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -145,28 +145,28 @@ static void GetHiddenValue(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsObject()); - 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; + if (!args[1]->Uint32Value(env->context()).To(&index)) return; + 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) { Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsObject()); - 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; + if (!args[1]->Uint32Value(env->context()).To(&index)) return; + 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) { From e76c50f20ff2d92d482c1354e78089890bff5648 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 15 Jun 2020 12:25:23 +0200 Subject: [PATCH 2/3] fixup! src: handle empty Maybe(Local) in node_util.cc --- src/node_util.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_util.cc b/src/node_util.cc index 0b743f2f5c04a5..a1893aa8fa155e 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -145,10 +145,10 @@ static void GetHiddenValue(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsObject()); + CHECK(args[1]->IsUint32()); Local obj = args[0].As(); - uint32_t index; - if (!args[1]->Uint32Value(env->context()).To(&index)) return; + uint32_t index = args[1].As()->Value(); Local private_symbol = IndexToPrivateSymbol(env, index); Local ret; if (obj->GetPrivate(env->context(), private_symbol).ToLocal(&ret)) From f78995a7ab8da13fb6a9e738094c335a5e93e505 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 15 Jun 2020 13:05:12 +0200 Subject: [PATCH 3/3] fixup! fixup! src: handle empty Maybe(Local) in node_util.cc --- src/node_util.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_util.cc b/src/node_util.cc index a1893aa8fa155e..eb956daac6c782 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -159,10 +159,10 @@ static void SetHiddenValue(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsObject()); + CHECK(args[1]->IsUint32()); Local obj = args[0].As(); - uint32_t index; - if (!args[1]->Uint32Value(env->context()).To(&index)) return; + 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))