From d3676ceeec55a41337ce5e6bc596f4f100d0638e Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Tue, 28 Feb 2017 18:28:53 +0100 Subject: in decRefAndDestroy() the remaining element must be one and only one So head can be destroyed already there and removeFromList() take a short cut. Change-Id: I8f53d252c4e0ad867674ee410ecfaa300ac0c731 --- sc/source/core/data/postit.cxx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'sc') diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 2e084c6b8e33..965d843aafc1 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -637,14 +637,11 @@ void ScCaptionPtr::decRefAndDestroy() * foo and call SdrObject::Free(), likely with mpHead->mpCaption, see * ScPostIt::RemoveCaption(). Further work needed to be able to do so. * */ - ScCaptionPtr* pThat = (mpHead ? mpHead->mpFirst : this); - do - { - pThat->mpCaption = nullptr; - pThat = pThat->mpNext; - } - while (pThat); - assert(!mpCaption); // this ought to be in list and nulled + assert(mpHead->mpFirst == this); // this must be one and only one + mpCaption = nullptr; + assert(!mpNext); // this must be one and only one + delete mpHead; + mpHead = nullptr; } } -- cgit v1.2.3