summaryrefslogtreecommitdiff
path: root/svl/source/items
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-07-10 00:05:35 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-07-10 06:35:12 +0900
commit4468ab0e0c0ecb50de68d2ecce327756a50eb0ae (patch)
treeea27ea7a02278ed05735963894566b472882553f /svl/source/items
parent6bcf07ec389ee78720e2dcfd66ee8ec57dd168a3 (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: I1dd003bc984a11d6d71c92aae44accc9d358db0c
Diffstat (limited to 'svl/source/items')
-rw-r--r--svl/source/items/itemprop.cxx9
-rw-r--r--svl/source/items/poolio.cxx4
2 files changed, 6 insertions, 7 deletions
diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx
index 41f1a0433055..3ba833fb1b17 100644
--- a/svl/source/items/itemprop.cxx
+++ b/svl/source/items/itemprop.cxx
@@ -22,6 +22,7 @@
#include <svl/itempool.hxx>
#include <svl/itemset.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <boost/scoped_ptr.hpp>
#include <boost/unordered_map.hpp>
/*************************************************************************
UNO III Implementation
@@ -242,7 +243,7 @@ void SfxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry& rEn
{
// get the SfxPoolItem
const SfxPoolItem* pItem = 0;
- SfxPoolItem *pNewItem = 0;
+ boost::scoped_ptr<SfxPoolItem> pNewItem;
SfxItemState eState = rSet.GetItemState( rEntry.nWID, true, &pItem );
if(SFX_ITEM_SET != eState && SFX_WHICH_MAX > rEntry.nWID )
pItem = &rSet.GetPool()->GetDefaultItem(rEntry.nWID);
@@ -253,23 +254,21 @@ void SfxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry& rEn
if(FillItem(aSet, rEntry.nWID, false))
{
const SfxPoolItem &rItem = aSet.Get(rEntry.nWID);
- pNewItem = rItem.Clone();
+ pNewItem.reset(rItem.Clone());
}
}
if(!pNewItem && pItem)
{
- pNewItem = pItem->Clone();
+ pNewItem.reset(pItem->Clone());
}
if(pNewItem)
{
if( !pNewItem->PutValue( aVal, rEntry.nMemberId ) )
{
- DELETEZ(pNewItem);
throw IllegalArgumentException();
}
// apply new item
rSet.Put( *pNewItem, rEntry.nWID );
- delete pNewItem;
}
}
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index ac481ba3ed59..08267a97df53 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -28,6 +28,7 @@
#include <svl/brdcst.hxx>
#include <svl/filerec.hxx>
#include "poolio.hxx"
+#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
/**
@@ -207,11 +208,10 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
{
sal_uLong nMark = rStream.Tell();
rStream.Seek( nItemStartPos + sizeof(sal_uInt16) );
- SfxPoolItem *pClone = pItem->Create(rStream, nItemVersion );
+ boost::scoped_ptr<SfxPoolItem> pClone(pItem->Create(rStream, nItemVersion ));
sal_uInt16 nWh = pItem->Which();
SFX_ASSERT( rStream.Tell() == nMark, nWh,"asymmetric store/create" );
SFX_ASSERT( *pClone == *pItem, nWh, "unequal after store/create" );
- delete pClone;
}
#endif
}