Skip to content

Commit

Permalink
Fixed crash with invalid category. Fixes #945.
Browse files Browse the repository at this point in the history
  • Loading branch information
leozide committed Oct 18, 2024
1 parent 3bf1420 commit 88a2308
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/lc_category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ bool lcMatchCategory(const char* PieceName, const char* Expression)
}
else if ((*p == '|') || (*p == '&'))
{
std::string LeftStr(Expression, (p - Expression) - 1);
std::string LeftStr(Expression, std::max(p - Expression, static_cast<ptrdiff_t>(1)) - 1);
std::string RightStr(p + 1);

if (*p == '|')
Expand Down Expand Up @@ -258,6 +258,9 @@ bool lcMatchCategory(const char* PieceName, const char* Expression)
Word++;
}

if (!Word[0])
return false;

const char* Result = strcasestr(PieceName, Word);

if (!Result)
Expand Down

0 comments on commit 88a2308

Please sign in to comment.