From bd591115a1acca0a131289f32f5673886895018b Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Mon, 17 Mar 2025 08:37:04 -0600 Subject: [PATCH] Avoid possible out of range index in MatchSpec::parse() (#3849) --- libmamba/src/specs/match_spec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmamba/src/specs/match_spec.cpp b/libmamba/src/specs/match_spec.cpp index fde395610..6826f2c2d 100644 --- a/libmamba/src/specs/match_spec.cpp +++ b/libmamba/src/specs/match_spec.cpp @@ -505,7 +505,7 @@ namespace mamba::specs auto MatchSpec::parse(std::string_view str) -> expected_parse_t { // Remove comments, i.e. everything after ` #` (space included) - if (const auto idx = str.find('#'); idx != std::string::npos && str[idx - 1] == ' ') + if (const auto idx = str.find(" #"); idx != std::string::npos) { str = str.substr(0, idx); }