diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-05-03 15:34:26 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-03 21:30:59 +0200 |
commit | fdbc12465e468ed50e4562268f44b24a73e22727 (patch) | |
tree | f4f1bde7ef32ebc6f4b22569a58090945640c2df /svl | |
parent | 27434647540b2bd3f30139983a3d5f7da9b77a44 (diff) |
ofz#14552 direct-leak
Change-Id: I8509b5805baca5b6357d7e266c05e3ff4404f4c1
Reviewed-on: https://gerrit.libreoffice.org/71754
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/itempool.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
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. |