summaryrefslogtreecommitdiff
path: root/basic/source/uno/namecont.cxx
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-05-31 00:09:32 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-05-31 00:35:27 +0900
commit6a53ea218c669b99aa9a51ce77898845f262b6e0 (patch)
treea0466ab24ec5046475f35b8dc8c47f3a386040a4 /basic/source/uno/namecont.cxx
parent95c0bc061d7f4cd218a0594eb66b504d4d308fad (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: Iad3de981a1c9660b1322315640e531c9891db0bf
Diffstat (limited to 'basic/source/uno/namecont.cxx')
-rw-r--r--basic/source/uno/namecont.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index e7cf8f34d11c..78fbb357a966 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -757,7 +757,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
}
else
{
- INetURLObject* pLibInfoInetObj = NULL;
+ boost::scoped_ptr<INetURLObject> pLibInfoInetObj;
if( meInitMode == CONTAINER_INIT_FILE )
{
aFileName = aInitFileName;
@@ -766,11 +766,11 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
{
if( nPass == 1 )
{
- pLibInfoInetObj = new INetURLObject( maLibraryPath.getToken(0, (sal_Unicode)';') );
+ pLibInfoInetObj.reset(new INetURLObject( maLibraryPath.getToken(0, (sal_Unicode)';') ));
}
else
{
- pLibInfoInetObj = new INetURLObject( maLibraryPath.getToken(1, (sal_Unicode)';') );
+ pLibInfoInetObj.reset(new INetURLObject( maLibraryPath.getToken(1, (sal_Unicode)';') ));
}
pLibInfoInetObj->insertName( maInfoFileName, false, INetURLObject::LAST_SEGMENT, true, INetURLObject::ENCODE_ALL );
pLibInfoInetObj->setExtension( OUString("xlc") );
@@ -805,8 +805,6 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
xInput.clear();
}
}
-
- delete pLibInfoInetObj;
}
if( xInput.is() )
@@ -816,11 +814,11 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
source.sSystemId = aFileName;
// start parsing
- ::xmlscript::LibDescriptorArray* pLibArray = new ::xmlscript::LibDescriptorArray();
+ boost::scoped_ptr< ::xmlscript::LibDescriptorArray> pLibArray(new ::xmlscript::LibDescriptorArray());
try
{
- xParser->setDocumentHandler( ::xmlscript::importLibraryContainer( pLibArray ) );
+ xParser->setDocumentHandler( ::xmlscript::importLibraryContainer( pLibArray.get() ) );
xParser->parseStream( source );
}
catch ( const xml::sax::SAXException& e )
@@ -973,7 +971,6 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
{
mbOldInfoFormat = false;
}
- delete pLibArray;
}
}