sw/source/core/txtnode/thints.cxx | 8 ++++++++ 1 file changed, 8 insertions(+)
New commits: commit 89eb90ceea414974289b57f15e769d08b80fe9a3 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Dec 1 14:04:56 2021 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Dec 3 10:17:11 2021 +0100 tdf#145062 sw: really destroy text attribute when insertion fails SwTextNode::InsertHint() is documented to destroy its argument SwTextAttr in case insertion fails, but it doesn't do it on all branches. Change-Id: I270df9acf36993d894899c20c86a6bc43d782001 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126190 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 5aba3a2b6e64..c7418514d31e 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1195,6 +1195,12 @@ void SwTextNode::DestroyAttr( SwTextAttr* pAttr ) SwTextField *const pTextField(static_txtattr_cast<SwTextField*>(pAttr)); SwFieldType* pFieldType = pAttr->GetFormatField().GetField()->GetTyp(); + if (SwFieldIds::Dde != pFieldType->Which() + && !pTextField->GetpTextNode()) + { + break; // was not yet inserted + } + //JP 06-08-95: DDE-fields are an exception assert(SwFieldIds::Dde == pFieldType->Which() || this == pTextField->GetpTextNode()); @@ -1613,6 +1619,7 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode ) if ( pAttr->End() == nullptr ) { bInsertHint = false; + DestroyAttr(pAttr); } else { @@ -2953,6 +2960,7 @@ bool SwpHints::TryInsertHint( if ( MAX_HINTS <= Count() ) // we're sorry, this flight is overbooked... { OSL_FAIL("hints array full :-("); + rNode.DestroyAttr(pHint); return false; }