From 96d8e464e522bfebc877f548f8cb893c14ab6882 Mon Sep 17 00:00:00 2001 From: Lars Viklund Date: Sun, 28 Apr 2024 14:52:56 +0200 Subject: [PATCH] fix: drop leading garbage from exact glob pattern Due to an unfortunate mixup of `resize()` vs. `reserve()` for the buffer containing the generated regex pattern for matching exact file paths, the buffer had garbage at the start leading to file searches not finding files if no wildcards were in effect. --- engine/system/win/sys_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/system/win/sys_main.cpp b/engine/system/win/sys_main.cpp index bd9ff4f..908585d 100644 --- a/engine/system/win/sys_main.cpp +++ b/engine/system/win/sys_main.cpp @@ -150,7 +150,8 @@ bool GlobMatch(const std::filesystem::path& glob, const std::filesystem::path& f // If no wildcards are present, test file path verbatim. // We use a regex rather than string comparisons to make it case-insensitive. if (globStr.find_first_of("?*") == std::string::npos) { - buf.resize(globStr.size()); + buf.reserve(globStr.size() * 3); // Decent estimate of final pattern size. + for (char ch : globStr) { fmt::format_to(fmt::appender(buf), "[{}]", ch); }