summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-10-15 21:35:06 +0200
committerMichael Stahl <mstahl@redhat.com>2014-10-15 23:44:55 +0200
commit3ec25899e05035ac882971637dfc9b6fa84437c9 (patch)
treef0955f19233ff86a46718e2e5d0d32aaa9f58ebc /sw
parent3b6ee58652d99accd610425264114d1d5b3330df (diff)
sw: fix temp file leak in SwIoSystem::GetFileFilter()
Change-Id: Id483d58a9de27a247880aedfe6bb3fe1d410129c
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/iodetect.hxx2
-rw-r--r--sw/source/filter/basflt/iodetect.cxx21
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx2
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx3
4 files changed, 12 insertions, 16 deletions
diff --git a/sw/inc/iodetect.hxx b/sw/inc/iodetect.hxx
index c3ed1e2d63b9..fca893ebd2c7 100644
--- a/sw/inc/iodetect.hxx
+++ b/sw/inc/iodetect.hxx
@@ -94,7 +94,7 @@ public:
/** Detect for the given file which filter should be used. The filter name
is returned. If no filter could be found, the name of the ASCII filter
is returned! */
- static const SfxFilter* GetFileFilter( const OUString& rFileName, const OUString& rPrefFltName, SfxMedium* pMedium = 0 );
+ static const SfxFilter* GetFileFilter(const OUString& rFileName);
static bool IsValidStgFilter( SotStorage& , const SfxFilter& );
static bool IsValidStgFilter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const SfxFilter& rFilter);
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() )
{
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index a39ad546b17a..141f9a2891e3 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -867,7 +867,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
if( bMergeShell || !pSourceDocSh->IsModified() )
{
const SfxFilter* pStoreToFilter = SwIoSystem::GetFileFilter(
- pSourceDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), ::aEmptyOUStr );
+ pSourceDocSh->GetMedium()->GetURLObject().GetMainURL(INetURLObject::NO_DECODE));
SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();
const OUString* pStoreToFilterOptions = 0;
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 18f79a541729..14ce7d61f2a6 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -2570,8 +2570,7 @@ bool SwTransferable::_PasteFileName( TransferableDataHelper& rData,
//Own FileFormat? --> insert, not for StarWriter/Web
OUString sFileURL = URIHelper::SmartRel2Abs(INetURLObject(), sFile, Link(), false );
const SfxFilter* pFlt = SW_PASTESDR_SETATTR == nAction
- ? 0 : SwIoSystem::GetFileFilter(
- sFileURL, aEmptyOUStr );
+ ? 0 : SwIoSystem::GetFileFilter(sFileURL);
if( pFlt && !rSh.GetView().GetDocShell()->ISA(SwWebDocShell) )
{
// and then pull up the insert-region-dialog by PostUser event