Fixed crash with invalid category. Fixes #945.

This commit is contained in:
Leonardo Zide
2024-10-18 12:35:55 -07:00
parent 3bf142051d
commit 88a23082f5
+4 -1
View File
@@ -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 == '|')
@@ -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)