svl/source/items/itempool.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
New commits: commit fdbc12465e468ed50e4562268f44b24a73e22727 Author: Caolán McNamara <[email protected]> AuthorDate: Fri May 3 15:34:26 2019 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri May 3 21:30:59 2019 +0200 ofz#14552 direct-leak Change-Id: I8509b5805baca5b6357d7e266c05e3ff4404f4c1 Reviewed-on: https://gerrit.libreoffice.org/71754 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 11be19bc62e0..8df891a247f5 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -631,17 +631,15 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW } } + const SfxPoolItem* pFoundItem = nullptr; // 2. search for an item with matching attributes. if (rItem.IsSortable()) { - auto pFoundItem = rItemArr.findByLessThan(&rItem); + pFoundItem = rItemArr.findByLessThan(&rItem); if (pFoundItem) { assert(*pFoundItem == rItem); AddRef(*pFoundItem); - if (bPassingOwnership) - delete &rItem; - return *pFoundItem; } } else @@ -650,12 +648,20 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW { if (**itr == rItem) { - AddRef(**itr); + pFoundItem = *itr; assert((!bPassingOwnership || (&rItem != *itr)) && "can't be passing ownership and have the item already in the pool"); - return **itr; + AddRef(**itr); + break; } } } + + if (pFoundItem) + { + if (bPassingOwnership) + delete &rItem; + return *pFoundItem; + } } // 3. not found, so clone to insert into the pointer array. _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
