From 809bf5e38cdb1fe304da9d413f07e9d7e66ce8f9 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 7 Jan 2016 21:56:10 +0100 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/4575 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/fs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fs.js b/lib/fs.js index 54e6b4ac0d2536..6f7a3cf2513bd8 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1550,7 +1550,7 @@ fs.realpathSync = function realpathSync(p, cache) { } } if (linkTarget === null) { - fs.statSync(base); + fs.accessSync(base, fs.F_OK); // Throws ELOOP on cyclic links. linkTarget = fs.readlinkSync(base); } resolvedLink = pathModule.resolve(previous, linkTarget);