summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-10-29 10:58:18 +0000
committerEike Rathke <erack@redhat.com>2013-10-29 12:16:33 +0000
commit66edf3c164176180c15dc768ce2b4518a9178183 (patch)
tree6782eb6dec17a42cc92f91c017140e6fa74f3946
parentd8e049d4e3971632eb08692905c60130731d9980 (diff)
Resolves: fdo#69510 don't access beyond end of string
Change-Id: Ib5d60159ad75791371a7805ef8e211a4010d7608 (cherry picked from commit 47690627565bec866ea2de74b5504160479cff74) Reviewed-on: https://gerrit.libreoffice.org/6472 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sw/source/core/text/portxt.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index 7dff0bdf485c..fd040168b2e9 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -160,7 +160,8 @@ static sal_Int32 lcl_AddSpace( const SwTxtSizeInfo &rInf, const OUString* pStr,
if ( bDoNotAddSpace )
return nCnt;
- for ( ; nPos < nEnd; ++nPos )
+ sal_Int32 nTxtEnd = std::min(nEnd, pStr->getLength());
+ for ( ; nPos < nTxtEnd; ++nPos )
{
if( CH_BLANK == (*pStr)[ nPos ] )
++nCnt;