summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorSimon Chenery <simon_chenery@yahoo.com>2025-01-28 19:51:15 +0100
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2025-02-03 11:26:32 +0100
commitad471148ec8763e17f55059aaf85e320175220f2 (patch)
tree5e34cd03656e99a794f8e5787a8d556ffec02dbe /forms
parent5be5e9da58c7dcee418264b2da29ddcc07e4709d (diff)
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.mehrbrodt@allotropia.de> Tested-by: Jenkins
Diffstat (limited to 'forms')
-rw-r--r--forms/source/xforms/convert.cxx2
1 files changed, 1 insertions, 1 deletions
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();
}