Skip to content

Commit 8c14942

Browse files
author
Evgeniy Gorbanyov
committed
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.
1 parent 19e0d47 commit 8c14942

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)