Skip to content

Commit 11e4cd6

Browse files
Eusgortargos
authored andcommitted
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. PR-URL: #58459 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent ca0f5a0 commit 11e4cd6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/node_api.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,9 @@ void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
704704
napi_addon_register_func init,
705705
int32_t module_api_version) {
706706
node::Environment* node_env = node::Environment::GetCurrent(context);
707+
CHECK_NOT_NULL(node_env);
707708
std::string module_filename = "";
708709
if (init == nullptr) {
709-
CHECK_NOT_NULL(node_env);
710710
node_env->ThrowError("Module has no declared entry point.");
711711
return;
712712
}

0 commit comments

Comments
 (0)