diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-02-21 12:56:57 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-02-21 14:11:02 +0100 |
commit | a1deb4f6f159c1e9cfbde8407399746c1a2ce556 (patch) | |
tree | bcccf39c0cd0488edebaebb92b9cd3e9fb7e0a5f /sw | |
parent | 9cc4302f0b9974b1933cbb7a5a190f3f7e6dbebd (diff) |
Make sure that mark does not exceed the length of the text
Change-Id: I685d3ac7f7038ef91463b2a0f012e23f0d6a422e
Reviewed-on: https://gerrit.libreoffice.org/68147
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/edit/acorrect.cxx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index 9c0858e744dc..6a32448dd082 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -380,17 +380,15 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, pTextNd->getLayoutFrame(rEditSh.GetLayout()))); assert(pFrame); - //JP 22.04.99: Bug 63883 - Special treatment for dots. - bool bLastCharIsPoint = nEndPos < pFrame->GetText().getLength() && - ('.' == pFrame->GetText()[nEndPos]); - + const OUString sFrameText = pFrame->GetText(); const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList( - pFrame->GetText(), rSttPos, nEndPos, *this, aLanguageTag); + sFrameText, rSttPos, nEndPos, *this, aLanguageTag); SwDoc* pDoc = rEditSh.GetDoc(); if( pFnd ) { // replace also last colon of keywords surrounded by colons (for example, ":name:") - bool replaceLastChar = pFnd->GetShort()[0] == ':' && pFnd->GetShort().endsWith(":"); + const bool replaceLastChar = sFrameText.getLength() > nEndPos && pFnd->GetShort()[0] == ':' + && pFnd->GetShort().endsWith(":"); SwPaM aPam(pFrame->MapViewToModelPos(TextFrameIndex(rSttPos)), pFrame->MapViewToModelPos(TextFrameIndex(nEndPos + (replaceLastChar ? 1 : 0)))); @@ -398,6 +396,8 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, if( pFnd->IsTextOnly() ) { //JP 22.04.99: Bug 63883 - Special treatment for dots. + const bool bLastCharIsPoint + = nEndPos < sFrameText.getLength() && ('.' == sFrameText[nEndPos]); if( !bLastCharIsPoint || pFnd->GetLong().isEmpty() || '.' != pFnd->GetLong()[ pFnd->GetLong().getLength() - 1 ] ) { |