diff options
author | Mark Wielaard <mark@klomp.org> | 2013-07-07 22:20:50 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-07-11 08:21:57 +0000 |
commit | 81a608e930c29f6210524df939c7a1d8b1093069 (patch) | |
tree | 905b3cacf5d6bb04e63de27ba9c2b2f923158efe /filter/source/msfilter | |
parent | f76173b517a17615241222f623e92f0f020dd2a8 (diff) |
Fix memory leak in SvxMSDffManager::CheckForConvertToSOObj.
Use boost::scoped_ptr for temporary SvMemoryStream.
Change-Id: I6235d7868bd20963aa5fdda32b1dd3b82cf0b182
Reviewed-on: https://gerrit.libreoffice.org/4760
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'filter/source/msfilter')
-rw-r--r-- | filter/source/msfilter/msdffimp.cxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index e6d8d1e890d1..58f455cdf1c7 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -136,6 +136,7 @@ #include <rtl/strbuf.hxx> #include <rtl/ustring.hxx> #include <boost/scoped_array.hpp> +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star ; using namespace ::com::sun::star::drawing; @@ -6838,17 +6839,17 @@ com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > SvxMS { //TODO/MBA: check if (and when) storage and stream will be destroyed! const SfxFilter* pFilter = 0; - SvMemoryStream* pStream = new SvMemoryStream; + ::boost::scoped_ptr<SvMemoryStream> xMemStream (new SvMemoryStream); if ( pName ) { // TODO/LATER: perhaps we need to retrieve VisArea and Metafile from the storage also SotStorageStreamRef xStr = rSrcStg.OpenSotStream( OUString( "package_stream" ), STREAM_STD_READ ); - *xStr >> *pStream; + *xStr >> *xMemStream; } else { SfxFilterMatcher aMatch( sStarName ); - SotStorageRef xStorage = new SotStorage( sal_False, *pStream ); + SotStorageRef xStorage = new SotStorage( sal_False, *xMemStream ); rSrcStg.CopyTo( xStorage ); xStorage->Commit(); xStorage.Clear(); @@ -6864,8 +6865,8 @@ com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > SvxMS aTmpName += OUString::number(nOleCount++); aTmpName += ".bin"; SvFileStream aTmpStream(aTmpName,STREAM_READ|STREAM_WRITE|STREAM_TRUNC); - pStream->Seek(0); - *pStream >> aTmpStream; + xMemStream->Seek(0); + *xMemStream >> aTmpStream; aTmpStream.Close(); #endif if ( pName || pFilter ) @@ -6882,7 +6883,7 @@ com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > SvxMS uno::Sequence < beans::PropertyValue > aMedium( aFilterName.isEmpty() ? 2 : 3); aMedium[0].Name = OUString( "InputStream" ); - uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( *pStream ); + uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( *xMemStream ); aMedium[0].Value <<= xStream; aMedium[1].Name = OUString( "URL" ); aMedium[1].Value <<= OUString( "private:stream" ); |