Compare commits

...

1 Commits

Author SHA1 Message Date
Claude Bot
30d4be6546 Fix segfault in N-API cleanup on process.exit
Adds null check in napi_internal_cleanup_env_cpp to prevent segmentation fault when process.exit() is called with a null or invalid napi_env pointer.

The crash occurred because cleanup hooks registered by N-API modules were executed during VM shutdown, but the napi_env pointer passed to the cleanup callback could be null.

Fixes #23353

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 22:41:18 +00:00

View File

@@ -2868,6 +2868,9 @@ extern "C" JS_EXPORT napi_status napi_remove_async_cleanup_hook(napi_async_clean
extern "C" void napi_internal_cleanup_env_cpp(napi_env env)
{
if (env == nullptr) {
return;
}
env->cleanup();
}