module: fix require.resolve() crash on non-string paths · nodejs/node@a274b28 · GitHub
Skip to content

Commit a274b28

Browse files
Aditi-1400targos
authored andcommitted
module: fix require.resolve() crash on non-string paths
Previously, `require.resolve()` could crash when: - The first parameter was a relative path and - The `paths` array contained non-string entries This commit fixes the issue by adding a check in `Module._findPath` to ensure all elements in `paths` are strings, and adding a validation in `stat` before calling `InternalModuleStat` to guard against non-string filenames. PR-URL: #56942 Fixes: #47698 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent b5a8a81 commit a274b28

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

lib/internal/modules/cjs/loader.js

Lines changed: 7 additions & 0 deletions
Lines changed: 18 additions & 0 deletions

0 commit comments

Comments
 (0)