From fd836b0ecf6528a43d7ac24ee72902ed8f3fbe73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Sverre=20Lien=20Sell=C3=A6g?= Date: Sat, 11 Mar 2023 15:35:04 +0100 Subject: [PATCH] skip very long lines as they probably arent the correct path and it fixes a crash when the regex match is to big --- src/project_build.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/project_build.cpp b/src/project_build.cpp index bc362c8..2ac28bd 100644 --- a/src/project_build.cpp +++ b/src/project_build.cpp @@ -147,6 +147,8 @@ boost::filesystem::path Project::CMakeBuild::get_executable(const boost::filesys return executable; } +const auto max_path_length_linux = 4095; + bool Project::CMakeBuild::is_valid(const boost::filesystem::path &build_path) const { if(project_path.empty() || build_path.empty()) return true; @@ -157,6 +159,9 @@ bool Project::CMakeBuild::is_valid(const boost::filesystem::path &build_path) co bool correct_source_dir = false; bool correct_cmake_command = false; while(std::getline(input, line)) { + if(line.size() >= max_path_length_linux) { + continue; + } const static std::regex source_dir_regex("^.*_SOURCE_DIR:STATIC=(.*)\r?$", std::regex::optimize); const static std::regex cmake_command_regex("^CMAKE_COMMAND:INTERNAL=(.*)\r?$", std::regex::optimize); std::smatch sm;