summaryrefslogtreecommitdiff
path: root/src/node_api.cc
diff options
context:
space:
mode:
authorGabriel Schulhof <gabriel.schulhof@intel.com>2018-05-16 11:05:32 -0400
committerGabriel Schulhof <gabriel.schulhof@intel.com>2018-05-23 22:14:52 -0400
commit9a02de7084e3f3c959d1c7e32bda67cc1d7002bd (patch)
treee9984e2a740d5964e891e0d695d25fbf19b5f462 /src/node_api.cc
parent82f18118ff8ddb7ad76f4c6bc40737e8fb8c20d2 (diff)
downloadnode-new-9a02de7084e3f3c959d1c7e32bda67cc1d7002bd.tar.gz
n-api: throw when entry point is null
PR-URL: https://github.com/nodejs/node/pull/20779 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_api.cc')
-rw-r--r--src/node_api.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node_api.cc b/src/node_api.cc
index fb3ea5df2c..a83244131f 100644
--- a/src/node_api.cc
+++ b/src/node_api.cc
@@ -868,6 +868,12 @@ void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context,
napi_addon_register_func init) {
+ if (init == nullptr) {
+ node::Environment::GetCurrent(context)->ThrowError(
+ "Module has no declared entry point.");
+ return;
+ }
+
// Create a new napi_env for this module or reference one if a pre-existing
// one is found.
napi_env env = v8impl::GetEnv(context);