Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fca38b2

Browse filesBrowse files
theanarkhtargos
authored andcommitted
src: use S_ISDIR to check if the file is a directory
PR-URL: #52164 Fixes: #52159 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 1f7c2a9 commit fca38b2
Copy full SHA for fca38b2

File tree

Expand file treeCollapse file tree

3 files changed

+17
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-3
lines changed
Open diff view settings
Collapse file

‎src/node_file.cc‎

Copy file name to clipboardExpand all lines: src/node_file.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ static void InternalModuleStat(const FunctionCallbackInfo<Value>& args) {
10541054
int rc = uv_fs_stat(env->event_loop(), &req, *path, nullptr);
10551055
if (rc == 0) {
10561056
const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr);
1057-
rc = !!(s->st_mode & S_IFDIR);
1057+
rc = S_ISDIR(s->st_mode);
10581058
}
10591059
uv_fs_req_cleanup(&req);
10601060

@@ -2982,7 +2982,7 @@ BindingData::FilePathIsFileReturnType BindingData::FilePathIsFile(
29822982

29832983
if (rc == 0) {
29842984
const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr);
2985-
rc = !!(s->st_mode & S_IFDIR);
2985+
rc = S_ISDIR(s->st_mode);
29862986
}
29872987

29882988
uv_fs_req_cleanup(&req);
Collapse file

‎src/permission/fs_permission.cc‎

Copy file name to clipboardExpand all lines: src/permission/fs_permission.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ std::string WildcardIfDir(const std::string& res) noexcept {
2121
int rc = uv_fs_stat(nullptr, &req, res.c_str(), nullptr);
2222
if (rc == 0) {
2323
const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr);
24-
if (s->st_mode & S_IFDIR) {
24+
if ((s->st_mode & S_IFMT) == S_IFDIR) {
2525
// add wildcard when directory
2626
if (res.back() == node::kPathSeparator) {
2727
return res + "*";
Collapse file
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
const common = require('../common');
3+
const fs = require('fs');
4+
const net = require('net');
5+
6+
const tmpdir = require('../common/tmpdir');
7+
tmpdir.refresh();
8+
9+
const server = net.createServer().listen(common.PIPE, common.mustCall(() => {
10+
// The process should not crash
11+
// See https://github.com/nodejs/node/issues/52159
12+
fs.readdirSync(tmpdir.path, { recursive: true });
13+
server.close();
14+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.