From 8c14942e5d1f2af9cd0e154a3bb88adf0d1df66f Mon Sep 17 00:00:00 2001 From: Evgeniy Gorbanyov Date: Mon, 26 May 2025 13:59:14 +0600 Subject: [PATCH] src: fix possible dereference of null pointer There is a CHECK_NOT_NULL check before dereferencing node_env on line 710 in the "if" block, but there is no CHECK_NOT_NULL check before dereferencing node_env on line 721. Maybe it makes sense to put CHECK_NOT_NULL right after calling the Environment::GetCurrent function. --- src/node_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_api.cc b/src/node_api.cc index 5c85ef063ecd77..b708f59ef362e0 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -704,9 +704,9 @@ void napi_module_register_by_symbol(v8::Local exports, napi_addon_register_func init, int32_t module_api_version) { node::Environment* node_env = node::Environment::GetCurrent(context); + CHECK_NOT_NULL(node_env); std::string module_filename = ""; if (init == nullptr) { - CHECK_NOT_NULL(node_env); node_env->ThrowError("Module has no declared entry point."); return; }