Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Elm <elmdominic@gmx.net>2021-09-02 16:17:42 +0300
committerBradley Farias <bradley.meck@gmail.com>2021-09-10 18:54:39 +0300
commita9dd03b1ec89a75186f05967fc76ec0704050c36 (patch)
treedb9cd062535160d91bd45f178b9761259ca9e2dd /src/node_binding.cc
parenta42bd7e944ed422adb78f767c7a9b3187989234a (diff)
src: add option to disable loading native addons
PR-URL: https://github.com/nodejs/node/pull/39977 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'src/node_binding.cc')
-rw-r--r--src/node_binding.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node_binding.cc b/src/node_binding.cc
index 3c9776e655d..050c5dff0ad 100644
--- a/src/node_binding.cc
+++ b/src/node_binding.cc
@@ -415,6 +415,12 @@ inline napi_addon_register_func GetNapiInitializerCallback(DLib* dlib) {
// cache that's a plain C list or hash table that's shared across contexts?
void DLOpen(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
+
+ if (env->no_native_addons()) {
+ return THROW_ERR_DLOPEN_DISABLED(
+ env, "Cannot load native addon because loading addons is disabled.");
+ }
+
auto context = env->context();
CHECK_NULL(thread_local_modpending);