Skip to content

Commit 78227c9

Browse files
trivikraduh95
authored andcommitted
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: #67007 Fixes: #67006 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
1 parent c617a93 commit 78227c9

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎src/node_ffi.cc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ void DynamicLibrary::New(const FunctionCallbackInfo<Value>& args) {
578578
opened ? static_cast<void*>(lib->lib_.handle) : nullptr);
579579
if (!opened) {
580580
THROW_ERR_FFI_CALL_FAILED(env, "dlopen failed: %s", uv_dlerror(&lib->lib_));
581+
// Free the error message. Close() skips uv_dlclose() for a null handle.
582+
uv_dlclose(&lib->lib_);
581583
return;
582584
}
583585
}

0 commit comments

Comments
 (0)