mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
src: release uv_fs_t in permission WildcardIfDir
Call uv_fs_req_cleanup() before returning for directories, otherwise the path buffer allocated by uv_fs_stat() leaks on Windows. Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: https://github.com/nodejs/node/pull/66555 Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
This commit is contained in:
1 parent
280ea2743b
commit
a67d2a8003
1 file changed
+10
-10
@@ -16,17 +16,17 @@ namespace {
|
||||
std::string WildcardIfDir(const std::string& res) noexcept {
|
||||
uv_fs_t req;
|
||||
int rc = uv_fs_stat(nullptr, &req, res.c_str(), nullptr);
|
||||
if (rc == 0) {
|
||||
const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr);
|
||||
if ((s->st_mode & S_IFMT) == S_IFDIR) {
|
||||
// add wildcard when directory
|
||||
if (res.back() == node::kPathSeparator) {
|
||||
return res + "*";
|
||||
}
|
||||
return res + node::kPathSeparator + "*";
|
||||
}
|
||||
}
|
||||
const bool is_dir =
|
||||
rc == 0 &&
|
||||
(static_cast<const uv_stat_t*>(req.ptr)->st_mode & S_IFMT) == S_IFDIR;
|
||||
uv_fs_req_cleanup(&req);
|
||||
if (is_dir) {
|
||||
// add wildcard when directory
|
||||
if (res.back() == node::kPathSeparator) {
|
||||
return res + "*";
|
||||
}
|
||||
return res + node::kPathSeparator + "*";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user