Skip to content

Commit e20d2ac

Browse files
committed
Avoid possible out of range index in MatchSpec::parse() (Fixes mamba-org#3809)
1 parent d9af139 commit e20d2ac

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libmamba/src/specs/match_spec.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,9 @@ namespace mamba::specs
505505
auto MatchSpec::parse(std::string_view str) -> expected_parse_t<MatchSpec>
506506
{
507507
// Remove comments, i.e. everything after ` #` (space included)
508-
if (const auto idx = str.find('#'); idx != std::string::npos && str[idx - 1] == ' ')
508+
if (const auto idx = str.find(" #"); idx != std::string::npos)
509509
{
510-
str = str.substr(0, idx);
510+
str = str.substr(0, idx + 1);
511511
}
512512

513513
// Remove trailing whitespaces

0 commit comments

Comments
 (0)