diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2024-02-23 17:18:04 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-02-24 09:44:41 +0100 |
commit | 5c4ae1b19c51dcd62dad8e1d3e8beb87a0311352 (patch) | |
tree | ca197ce04ce25a1db6478d067c5907b6e064ea83 /sw/inc | |
parent | ce6f91863fb7ad1c1f129a23202aefeba3378dbc (diff) |
tdf#147731 sw: fix memory leak in SwDoc::CopyPageDesc()
Commit 963de9feb37105560fde14b44d992e47f341bb5b "sw: fix issue with
copying stashed frame format" fixed the actual bug here, but introduced
a new memory leak.
This causes an assert in CppunitTest_uiwriter3:
cppunittester: svl/source/items/itempool.cxx:779: void SfxItemPool::Remove(const SfxPoolItem&): Assertion `rItem.GetRefCount() && "RefCount == 0, Remove impossible"' failed.
The assert happens only when this is backported to the libreoffice-7-6
branch, because commit ab7c81f55621d7b0d1468c63305163016dd78837 "ITEM:
Get away from classic 'poolable' Item flag" removed the assert.
The problem is that a SwFormatFrameSize inside a footer SwFrameFormat is
leaked 4 times, because 4 SwFrameFormats are leaked; the leak is that
SwDoc::CopyPageDesc() creates a new pNewFormat, passed it to
StashFrameFormat(), which copies it but doesn't free it.
There is also a usage of std::shared_ptr here that is very questionable;
SwFrameFormat should never be shared between different SwPageDesc.
(regression from commit b802ab694a8a7357d4657f3e11b571144fa7c7bf)
Change-Id: I44133bc5e6789a51ce064f1aa5ea8b325224365b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163854
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/pagedesc.hxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index 136117114b30..3ec919ce3c83 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -151,9 +151,9 @@ class SW_DLLPUBLIC SwPageDesc final struct StashedPageDesc { - std::shared_ptr<SwFrameFormat> m_pStashedFirst; - std::shared_ptr<SwFrameFormat> m_pStashedLeft; - std::shared_ptr<SwFrameFormat> m_pStashedFirstLeft; + std::optional<SwFrameFormat> m_oStashedFirst; + std::optional<SwFrameFormat> m_oStashedLeft; + std::optional<SwFrameFormat> m_oStashedFirstLeft; }; mutable StashedPageDesc m_aStashedHeader; |