summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2023-05-02 11:59:52 +0100
committerCaolán McNamara <caolanm@redhat.com>2023-05-02 16:17:49 +0200
commit46e40f2f7c742ffe01833551bb2843d156716be0 (patch)
treefc932b88a1573a6956ca443530abef8979c11539 /sw
parent30334be31f190b5da79f3ba2bec94b2ff35ad72c (diff)
ofz#58550 Direct-leak in writer layout
Change-Id: Id29138896a8da7a6badbeecfb0df24171c51f145 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151264 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/text/itrform2.cxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index f754e13c63a4..1eae79dc4125 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -540,6 +540,15 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf )
SwKernPortion* pKrn =
new SwKernPortion( *rInf.GetLast(), nLstHeight,
pLast->InFieldGrp() && pPor->InFieldGrp() );
+
+ // ofz#58550 Direct-leak, pKrn adds itself as the NextPortion
+ // of rInf.GetLast(), but may use CopyLinePortion to add a copy
+ // of itself, which will then be left dangling with the following
+ // SetNextPortion(nullptr)
+ SwLinePortion *pNext = rInf.GetLast()->GetNextPortion();
+ if (pNext != pKrn)
+ delete pNext;
+
rInf.GetLast()->SetNextPortion( nullptr );
InsertPortion( rInf, pKrn );
}