diff options
-rw-r--r-- | sw/source/core/text/portxt.cxx | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 01afab67d721..ff20cc1fe98b 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -161,7 +161,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; |