Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
prevent poisoning Module._pathCache with snapshot fs value
Browse files Browse the repository at this point in the history
  • Loading branch information
igorklopov committed Jul 14, 2017
1 parent d3228e2 commit f7a9b71
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions prelude/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1186,18 +1186,21 @@ function payloadFileSync (pointer) {

Module._resolveFilename = function () {
var filename;
var flagWas = false;
var flagWasOn = false;

try {
filename = ancestor._resolveFilename.apply(this, arguments);
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') throw error;

FLAG_ENABLE_PROJECT = true;
var savePathCache = Module._pathCache;
Module._pathCache = Object.create(null);
try {
filename = ancestor._resolveFilename.apply(this, arguments);
flagWas = true;
flagWasOn = true;
} finally {
Module._pathCache = savePathCache;
FLAG_ENABLE_PROJECT = false;
}
}
Expand All @@ -1209,7 +1212,7 @@ function payloadFileSync (pointer) {
return filename;
}

FLAG_ENABLE_PROJECT = flagWas;
FLAG_ENABLE_PROJECT = flagWasOn;
try {
var found = findNativeAddonSync(filename);
if (found) filename = found;
Expand Down

0 comments on commit f7a9b71

Please sign in to comment.