diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-11 21:47:43 +0000 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-04-12 17:44:26 +0200 |
commit | 177589cb4f8ef20ff84dbfc141b145b28e57be83 (patch) | |
tree | 28a67d311d602a324380e7129de9501e61d46046 | |
parent | ofz: Use-of-uninitialized-value (diff) | |
download | core-177589cb4f8ef20ff84dbfc141b145b28e57be83.tar.gz core-177589cb4f8ef20ff84dbfc141b145b28e57be83.zip |
an inconsistent SwTextFormatInfo index, len, text length case
seen on loading sw/qa/python/testdocuments/TESTMETA.odt
maybe since:
commit 2f3684b2289a8c46dc6144064a452cc529400f28
Date: Tue Jul 31 16:00:02 2018 +0200
[API CHANGE] add some more asserts to the string functions
but probably an underlying issue since conversion from UniString
to OUString
Change-Id: If731163fbc5e05b813ccd21df65164fe476cba9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131407
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit eb7fbe1f3a37d89b97bd8976bdc006099578c204)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132860
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | sw/source/core/text/porfld.cxx | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 21ab8eecd351..4178ea35f34a 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -175,10 +175,18 @@ SwFieldSlot::SwFieldSlot( const SwTextFormatInfo* pNew, const SwFieldPortion *pP pInf->SetFakeLineStart( nIdx > pInf->GetLineStart() ); pInf->SetIdx(TextFrameIndex(0)); } - else if (nIdx < TextFrameIndex(pOldText->getLength())) + else { - sal_Int32 const nFieldLen(pPor->GetFieldLen()); - aText = (*pOldText).replaceAt(sal_Int32(nIdx), nFieldLen, aText); + TextFrameIndex nEnd(pOldText->getLength()); + if (nIdx < nEnd) + { + sal_Int32 const nFieldLen(pPor->GetFieldLen()); + aText = (*pOldText).replaceAt(sal_Int32(nIdx), nFieldLen, aText); + } + else if (nIdx == nEnd) + aText = *pOldText + aText; + else + SAL_WARN("sw.core", "SwFieldSlot bad SwFieldPortion index."); } pInf->SetText( aText ); } |