From 52e4967f45098a8f97ba618bad8dc30a887ebece Mon Sep 17 00:00:00 2001 From: Justin Nietzel Date: Wed, 9 Apr 2025 16:51:27 -0400 Subject: [PATCH] fs: add missing call to uv_fs_req_cleanup Always call uv_fs_req_cleanup after calling uv_fs_open instead of just when uv_fs_open returns a negative result. I referenced ReadFileSync from node:js2c when making this change. https://github.com/bnoordhuis made the same suggestion based on the PR https://github.com/nodejs/node/pull/49691. Fixes: https://github.com/nodejs/node/issues/57800 PR-URL: https://github.com/nodejs/node/pull/57811 Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- src/node_file.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_file.cc b/src/node_file.cc index b2e3889b412..794a9ba9120 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -2711,10 +2711,10 @@ static void ReadFileUtf8(const FunctionCallbackInfo& args) { FS_SYNC_TRACE_END(open); if (req.result < 0) { uv_fs_req_cleanup(&req); - // req will be cleaned up by scope leave. return env->ThrowUVException( static_cast(req.result), "open", nullptr, path.out()); } + uv_fs_req_cleanup(&req); } auto defer_close = OnScopeLeave([file, is_fd, &req]() {