From 88a23082f5893c045e7ee22c4f52ea7018c4ff6f Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Fri, 18 Oct 2024 12:35:55 -0700 Subject: [PATCH] Fixed crash with invalid category. Fixes #945. --- common/lc_category.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/lc_category.cpp b/common/lc_category.cpp index 83de802b..3899f423 100644 --- a/common/lc_category.cpp +++ b/common/lc_category.cpp @@ -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(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)