From 441ef4d7f03131ddfd6e82e405bdd3640ec5bf5a Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 15 Feb 2019 11:48:56 +0100 Subject: n-api: do not call into JS when that is not allowed Check whether calling into JS is allowed before doing so. PR-URL: https://github.com/nodejs/node/pull/26127 Reviewed-By: Gus Caplan Reviewed-By: Michael Dawson --- src/node_api.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/node_api.cc') diff --git a/src/node_api.cc b/src/node_api.cc index ff2e12f571..010fb3fe0f 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -12,9 +12,14 @@ struct node_napi_env__ : public napi_env__ { napi_env__(context) { CHECK_NOT_NULL(node_env()); } + inline node::Environment* node_env() const { return node::Environment::GetCurrent(context()); } + + bool can_call_into_js() const override { + return node_env()->can_call_into_js(); + } }; typedef node_napi_env__* node_napi_env; -- cgit v1.2.3