@@ -181,6 +181,7 @@ const {
|
181 | 181 | |
182 | 182 | const { |
183 | 183 | codes: { |
| 184 | +ERR_INVALID_ARG_TYPE, |
184 | 185 | ERR_INVALID_ARG_VALUE, |
185 | 186 | ERR_INVALID_MODULE_SPECIFIER, |
186 | 187 | ERR_REQUIRE_CYCLE_MODULE, |
@@ -246,6 +247,9 @@ function wrapModuleLoad(request, parent, isMain) {
|
246 | 247 | * @param {string} filename Absolute path to the file |
247 | 248 | */ |
248 | 249 | function stat(filename) { |
| 250 | +// Guard against internal bugs where a non-string filename is passed in by mistake. |
| 251 | +assert(typeof filename === 'string'); |
| 252 | + |
249 | 253 | filename = path.toNamespacedPath(filename); |
250 | 254 | if (statCache !== null) { |
251 | 255 | const result = statCache.get(filename); |
@@ -738,6 +742,9 @@ Module._findPath = function(request, paths, isMain, conditions = getCjsCondition
|
738 | 742 | for (let i = 0; i < paths.length; i++) { |
739 | 743 | // Don't search further if path doesn't exist |
740 | 744 | const curPath = paths[i]; |
| 745 | +if (typeof curPath !== 'string') { |
| 746 | +throw new ERR_INVALID_ARG_TYPE('paths', 'array of strings', paths); |
| 747 | +} |
741 | 748 | if (insidePath && curPath && _stat(curPath) < 1) { |
742 | 749 | continue; |
743 | 750 | } |
|