diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-09 17:10:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-10 08:30:21 +0200 |
commit | 65e41592a650887c8d00586385119effa54de5fa (patch) | |
tree | 4b0f6c7f52159d9cf70c561c815f623d3b57198d /svl/source | |
parent | acb7c06ab171d4201842d8183eefeeca2d28c3f5 (diff) |
pass SvStream around by std::unique_ptr
and give utl::OStreamWrapper a new constructor so that it knows it is
taking ownership of the SvStream, which appears to fix several leaks
Change-Id: Idcbcca9b81a4f0345fd8b8c8a2f4e84213686a6b
Reviewed-on: https://gerrit.libreoffice.org/57187
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl/source')
-rw-r--r-- | svl/source/fsstor/fsstorage.cxx | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx index 3d21e23c3b0c..6a28dc07d422 100644 --- a/svl/source/fsstor/fsstorage.cxx +++ b/svl/source/fsstor/fsstorage.cxx @@ -369,14 +369,12 @@ uno::Reference< io::XStream > SAL_CALL FSStorage::openStreamElement( else { // TODO: test whether it really works for http and fwp - SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), + std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::STD_WRITE ); if ( pStream ) { if ( !pStream->GetError() ) - xResult.set( new ::utl::OStreamWrapper( *pStream ) ); - else - delete pStream; + xResult.set( new ::utl::OStreamWrapper( std::move(pStream) ) ); } } @@ -1208,18 +1206,16 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL FSStorage::openStreamEl else { // TODO: test whether it really works for http and fwp - SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aFileURL, + std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream( aFileURL, StreamMode::STD_WRITE ); if ( pStream ) { if ( !pStream->GetError() ) { uno::Reference< io::XStream > xStream = - uno::Reference < io::XStream >( new ::utl::OStreamWrapper( *pStream ) ); + uno::Reference < io::XStream >( new ::utl::OStreamWrapper( std::move(pStream) ) ); xResult = static_cast< io::XStream* >( new OFSStreamContainer( xStream ) ); } - else - delete pStream; } } |