diff --git a/src/node_ffi.cc b/src/node_ffi.cc index fe110eeae8e..d6c50757f4f 100644 --- a/src/node_ffi.cc +++ b/src/node_ffi.cc @@ -578,6 +578,8 @@ void DynamicLibrary::New(const FunctionCallbackInfo& args) { opened ? static_cast(lib->lib_.handle) : nullptr); if (!opened) { THROW_ERR_FFI_CALL_FAILED(env, "dlopen failed: %s", uv_dlerror(&lib->lib_)); + // Free the error message. Close() skips uv_dlclose() for a null handle. + uv_dlclose(&lib->lib_); return; } }