Skip to content

Commit 809bf5e

Browse files
bnoordhuisjasnell
authored andcommitted
fs: change statSync to accessSync in realpathSync
fs.statSync() creates and returns a heavy-weight fs.Stat object whereas fs.accessSync() simply returns nothing. The return value is ignored, the call is for its side effect of throwing an ELOOP error in case of cyclic symbolic links. PR-URL: #4575 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d8ba2c0 commit 809bf5e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/fs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ fs.realpathSync = function realpathSync(p, cache) {
15501550
}
15511551
}
15521552
if (linkTarget === null) {
1553-
fs.statSync(base);
1553+
fs.accessSync(base, fs.F_OK); // Throws ELOOP on cyclic links.
15541554
linkTarget = fs.readlinkSync(base);
15551555
}
15561556
resolvedLink = pathModule.resolve(previous, linkTarget);

0 commit comments

Comments
 (0)