Add isEmpty() to avoid possible OUString underflow in HelpSearch.cxx

Avoid accessing invalid index -1 if OUString queryStr is empty.

It cannot be guaranteed that callers will always pass a non-empty
value for queryStr.

Change-Id: I759a4caea5d52371467f58bb5b95edbd3ff7d4d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181850
Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Simon Chenery
2025-03-17 16:49:37 +01:00
committed by Ilmari Lauhakangas
parent d022499ada
commit 478920da08
+1 -1
View File
@@ -29,7 +29,7 @@ void HelpSearch::query(OUString const &queryStr, bool captionOnly,
const TCHAR* field = captionOnly ? L"caption" : L"content";
bool isWildcard = queryStr[queryStr.getLength() - 1] == L'*';
const bool isWildcard = (!queryStr.isEmpty() && queryStr[queryStr.getLength() - 1] == L'*');
std::vector<TCHAR> aQueryStr(OUStringToTCHARVec(queryStr));
lucene::search::Query *pQuery;
if (isWildcard)