From 7f0acedf9b5a7544f88af426d7ed3cf0e58176dd Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 3 Oct 2013 09:30:46 +0100 Subject: CID#441342 potential resource leak Change-Id: Ia39e8c53427347088aa8d58ae1220950f191cd91 --- sot/source/sdstor/ucbstorage.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sot') diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index 0e428dab4b25..b0801e3a0060 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -2139,15 +2140,15 @@ sal_Int16 UCBStorage_Impl::Commit() { UCBStorageElement_Impl* pElement = m_aChildrenList[ i ]; ::ucbhelper::Content* pContent = pElement->GetContent(); - bool bDeleteContent = false; + boost::scoped_ptr< ::ucbhelper::Content > xDeleteContent; if ( !pContent && pElement->IsModified() ) { // if the element has never been opened, no content has been created until now - bDeleteContent = true; // remember to delete it later OUString aName( m_aURL ); aName += "/"; aName += pElement->m_aOriginalName; pContent = new ::ucbhelper::Content( aName, Reference< ::com::sun::star::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() ); + xDeleteContent.reset(pContent); // delete it later on exit scope } if ( pElement->m_bIsRemoved ) @@ -2220,10 +2221,6 @@ sal_Int16 UCBStorage_Impl::Commit() nRet = nLocalRet; } - if ( bDeleteContent ) - // content was created inside the loop - delete pContent; - if ( nRet == COMMIT_RESULT_FAILURE ) break; } -- cgit v1.2.3