ffi: free libuv error message on failed dlopen

When uv_dlopen() fails, the error message it allocates is only
released by uv_dlclose(). DynamicLibrary::Close() skips uv_dlclose()
when the handle is null, so each failed ffi.dlopen() leaked the
message. Call uv_dlclose() on the failure path, as DLib::Open() does.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/67007
Fixes: https://github.com/nodejs/node/issues/67006
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
This commit is contained in:
Trivikram Kamat authored and Antoine du Hamel committed 2026-11-12 17:45:25 +01:00
1 parent 62f8c7485e
commit 7145dcb47c
1 file changed
+2
+2
View File
@@ -578,6 +578,8 @@ void DynamicLibrary::New(const FunctionCallbackInfo<Value>& args) {
opened ? static_cast<void*>(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;
}
}