forms/source/xforms/convert.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ad471148ec8763e17f55059aaf85e320175220f2
Author:     Simon Chenery <simon_chen...@yahoo.com>
AuthorDate: Tue Jan 28 19:51:15 2025 +0100
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Mon Feb 3 11:26:32 2025 +0100

    Add isEmpty() check to avoid possible OUStringBuffer underflow
    
    Avoid accessing invalid index -1 if OUStringBuffer aBuffer is empty.
    
    It cannot be guaranteed that callers will always pass strings that
    result in aBuffer being non-empty.
    
    Change-Id: Ied9abf753bcaf2bd1ee618b2431fa35b0bdb5573
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180856
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
    Tested-by: Jenkins

diff --git a/forms/source/xforms/convert.cxx b/forms/source/xforms/convert.cxx
index c95d5fae6856..98fd3391f220 100644
--- a/forms/source/xforms/convert.cxx
+++ b/forms/source/xforms/convert.cxx
@@ -328,7 +328,7 @@ OUString Convert::collapseWhitespace( const OUString& 
_rString )
             aBuffer.append( c );
         }
     }
-    if( aBuffer[ aBuffer.getLength() - 1 ] == u' ' )
+    if( !aBuffer.isEmpty() && aBuffer[ aBuffer.getLength() - 1 ] == u' ' )
         aBuffer.setLength( aBuffer.getLength() - 1 );
     return aBuffer.makeStringAndClear();
 }

Reply via email to