lsp: Limit resolvesToRegularFile()'s recursion depth to 10.

This commit is contained in:
Christian Parpart 2022-08-24 15:46:08 +02:00
parent 3fc7debbef
commit c8074d2c6e

View File

@ -58,14 +58,15 @@ namespace fs = boost::filesystem;
namespace
{
bool resolvesToRegularFile(boost::filesystem::path _path)
bool resolvesToRegularFile(boost::filesystem::path _path, int maxRecursionDepth = 10)
{
fs::file_status fileStatus = fs::status(_path);
while (fileStatus.type() == fs::file_type::symlink_file)
while (fileStatus.type() == fs::file_type::symlink_file && maxRecursionDepth > 0)
{
_path = boost::filesystem::read_symlink(_path);
fileStatus = fs::status(_path);
maxRecursionDepth--;
}
return fileStatus.type() == fs::file_type::regular_file;