helpcompiler/source/HelpSearch.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 478920da0895d8c55827cda8f1d20e1b7fa511ea
Author:     Simon Chenery <simon_chen...@yahoo.com>
AuthorDate: Tue Feb 18 19:55:58 2025 +0100
Commit:     Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
CommitDate: Mon Mar 17 16:49:37 2025 +0100

    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.lauhakan...@libreoffice.org>
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/helpcompiler/source/HelpSearch.cxx 
b/helpcompiler/source/HelpSearch.cxx
index 982e672c4573..8e6e8d9ecadf 100644
--- a/helpcompiler/source/HelpSearch.cxx
+++ b/helpcompiler/source/HelpSearch.cxx
@@ -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)

Reply via email to