mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
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:
1 parent
62f8c7485e
commit
7145dcb47c
1 file changed
+2
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user