diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-10-15 21:35:06 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-10-15 23:44:55 +0200 |
commit | 3ec25899e05035ac882971637dfc9b6fa84437c9 (patch) | |
tree | f0955f19233ff86a46718e2e5d0d32aaa9f58ebc /sw/source/filter/basflt/iodetect.cxx | |
parent | 3b6ee58652d99accd610425264114d1d5b3330df (diff) |
sw: fix temp file leak in SwIoSystem::GetFileFilter()
Change-Id: Id483d58a9de27a247880aedfe6bb3fe1d410129c
Diffstat (limited to 'sw/source/filter/basflt/iodetect.cxx')
-rw-r--r-- | sw/source/filter/basflt/iodetect.cxx | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx index c6fdded62c63..9c60782a8e05 100644 --- a/sw/source/filter/basflt/iodetect.cxx +++ b/sw/source/filter/basflt/iodetect.cxx @@ -198,9 +198,7 @@ void TerminateBuffer(sal_Char *pBuffer, sal_uLong nBytesRead, sal_uLong nBufferL // Check the type of the stream (file) by searching for corresponding set of bytes. // If no known type is found, return ASCII for now! // Returns the internal FilterName. -// rPrefFltName is the internal FilterName that was chosen by the user in the Open Dlg. -const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName, - const OUString& rPrefFltName, SfxMedium* pMedium) +const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName) { SfxFilterContainer aCntSw( OUString(sSWRITER) ); SfxFilterContainer aCntSwWeb( OUString(sSWRITERWEB) ); @@ -212,21 +210,20 @@ const SfxFilter* SwIoSystem::GetFileFilter(const OUString& rFileName, if ( !pFilter ) return 0; - if( pMedium ? ( pMedium->IsStorage() || SotStorage::IsStorageFile( pMedium->GetInStream() ) ) : SotStorage::IsStorageFile( rFileName ) ) + ::boost::scoped_ptr<SfxMedium> pMedium; + if (SotStorage::IsStorageFile(rFileName)) { // package storage or OLEStorage based format SotStorageRef xStg; - if (!pMedium ) - { - INetURLObject aObj; - aObj.SetSmartProtocol( INET_PROT_FILE ); - aObj.SetSmartURL( rFileName ); - pMedium = new SfxMedium( aObj.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READ ); - } + INetURLObject aObj; + aObj.SetSmartProtocol( INET_PROT_FILE ); + aObj.SetSmartURL( rFileName ); + pMedium.reset(new SfxMedium(aObj.GetMainURL(INetURLObject::NO_DECODE), STREAM_STD_READ)); // templates should not get precedence over "normal" filters (#i35508, #i33168) const SfxFilter* pTemplateFilter = 0; - const SfxFilter* pOldFilter = pFCntnr->GetFilter4FilterName( rPrefFltName ); + const SfxFilter* pOldFilter = pFCntnr->GetFilter4FilterName(""); + assert(!pOldFilter); bool bLookForTemplate = pOldFilter && pOldFilter->IsOwnTemplateFormat(); if ( pMedium->IsStorage() ) { |