summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-09-17 12:58:21 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-09-17 18:21:57 +0200
commit64b7ff9f6ca03561d2d3db86d464545b282d4a3a (patch)
tree0ac8379e206e90b65782c90717788f194e3e6c6c /svx/source
parent1b3fc6e2b8f3f36868657d623de21ce3e249efa0 (diff)
fix leak on exceptions
Change-Id: I88201acb472dbdb2c3b49945b962c5f2689d3bae Reviewed-on: https://gerrit.libreoffice.org/42376 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/unodraw/UnoNameItemTable.cxx19
1 files changed, 9 insertions, 10 deletions
diff --git a/svx/source/unodraw/UnoNameItemTable.cxx b/svx/source/unodraw/UnoNameItemTable.cxx
index aad9ddc5949d..0a50dc3cfac2 100644
--- a/svx/source/unodraw/UnoNameItemTable.cxx
+++ b/svx/source/unodraw/UnoNameItemTable.cxx
@@ -82,11 +82,11 @@ void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, cons
{
maItemSetVector.push_back( o3tl::make_unique< SfxItemSet >( *mpModelPool, std::initializer_list<SfxItemSet::Pair>{{mnWhich, mnWhich}} ) );
- std::unique_ptr<NameOrIndex> pNewItem(createItem());
- pNewItem->SetName( aName );
- pNewItem->PutValue( aElement, mnMemberId );
- pNewItem->SetWhich(mnWhich);
- maItemSetVector.back()->Put( *pNewItem );
+ std::unique_ptr<NameOrIndex> xNewItem(createItem());
+ xNewItem->SetName(aName);
+ xNewItem->PutValue(aElement, mnMemberId);
+ xNewItem->SetWhich(mnWhich);
+ maItemSetVector.back()->Put(*xNewItem);
}
// XNameContainer
@@ -153,12 +153,11 @@ void SAL_CALL SvxUnoNameItemTable::replaceByName( const OUString& aApiName, cons
const NameOrIndex *pItem = static_cast<const NameOrIndex *>(&((*aIter)->Get( mnWhich ) ));
if (aName == pItem->GetName())
{
- NameOrIndex* pNewItem = createItem();
- pNewItem->SetName(aName);
- if( !pNewItem->PutValue( aElement, mnMemberId ) || !isValid( pNewItem ) )
+ std::unique_ptr<NameOrIndex> xNewItem(createItem());
+ xNewItem->SetName(aName);
+ if (!xNewItem->PutValue(aElement, mnMemberId) || !isValid(xNewItem.get()))
throw lang::IllegalArgumentException();
-
- (*aIter)->Put( *pNewItem );
+ (*aIter)->Put(*xNewItem);
return;
}
++aIter;