summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-12-23 19:32:50 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-12-27 20:33:05 +0100
commit2d348132ab307e866dc2be8282b6e16aac65d29d (patch)
treebc9e817b2ddbc3134cc418317894b1aaa090d43a /sd
parent2f269aae084a7366a6111185f86a5e852629dfa8 (diff)
ofz#28918 Direct-Leak in SotStorage::OpenSotStream
Change-Id: I2d99a13822b07d98e03d7e7de91ca44ab4f8599d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108266 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/eppt/eppt.cxx12
-rw-r--r--sd/source/filter/eppt/eppt.hxx7
-rw-r--r--sd/source/filter/ppt/pptin.cxx10
-rw-r--r--sd/source/filter/ppt/pptin.hxx2
-rw-r--r--sd/source/filter/sdpptwrp.cxx2
5 files changed, 19 insertions, 14 deletions
diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx
index 5c1f9da7d7af..237fd2276f5d 100644
--- a/sd/source/filter/eppt/eppt.cxx
+++ b/sd/source/filter/eppt/eppt.cxx
@@ -106,12 +106,12 @@ void PPTWriter::exportPPTPre( const std::vector< css::beans::PropertyValue >& rM
if ( !ImplCreateCurrentUserStream() )
return;
- mpStrm.reset( mrStg->OpenSotStream( "PowerPoint Document" ) );
+ mpStrm = mrStg->OpenSotStream( "PowerPoint Document" );
if ( !mpStrm )
return;
if ( !mpPicStrm )
- mpPicStrm.reset( mrStg->OpenSotStream( "Pictures" ) );
+ mpPicStrm = mrStg->OpenSotStream( "Pictures" );
auto aIter = std::find_if(rMediaData.begin(), rMediaData.end(),
[](const css::beans::PropertyValue& rProp) { return rProp.Name == "BaseURI"; });
@@ -448,9 +448,9 @@ PPTWriter::~PPTWriter()
{
mpExEmbed.reset();
mpPptEscherEx.reset();
- mpCurUserStrm.reset();
- mpPicStrm.reset();
- mpStrm.reset();
+ mpCurUserStrm.clear();
+ mpPicStrm.clear();
+ mpStrm.clear();
maStyleSheetList.clear();
maExOleObj.clear();
if ( mbStatusIndicator )
@@ -459,7 +459,7 @@ PPTWriter::~PPTWriter()
bool PPTWriter::ImplCreateCurrentUserStream()
{
- mpCurUserStrm.reset( mrStg->OpenSotStream( "Current User" ) );
+ mpCurUserStrm = mrStg->OpenSotStream( "Current User" );
if ( !mpCurUserStrm )
return false;
char pUserName[] = "Current User";
diff --git a/sd/source/filter/eppt/eppt.hxx b/sd/source/filter/eppt/eppt.hxx
index 04255e711d99..bed711891345 100644
--- a/sd/source/filter/eppt/eppt.hxx
+++ b/sd/source/filter/eppt/eppt.hxx
@@ -23,6 +23,7 @@
#include <vector>
#include "escherex.hxx"
#include <sal/types.h>
+#include <sot/storage.hxx>
#include "pptexsoundcollection.hxx"
#include "text.hxx"
@@ -127,9 +128,9 @@ class PPTWriter final : public PPTWriterBase, public PPTExBulletProvider
sal_uInt32 mnTextSize;
tools::SvRef<SotStorage> mrStg;
- std::unique_ptr<SvStream> mpCurUserStrm;
- std::unique_ptr<SvStream> mpStrm;
- std::unique_ptr<SvStream> mpPicStrm;
+ tools::SvRef<SotStorageStream> mpCurUserStrm;
+ tools::SvRef<SotStorageStream> mpStrm;
+ tools::SvRef<SotStorageStream> mpPicStrm;
std::unique_ptr<PptEscherEx> mpPptEscherEx;
std::vector<std::unique_ptr<PPTExOleObjEntry>> maExOleObj;
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 254da0754bba..f9831e0969e7 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -125,8 +125,8 @@ SdPPTImport::SdPPTImport( SdDrawDocument* pDocument, SvStream& rDocStream, SotSt
pSummaryInformation.reset();
#endif
- if (auto pCurrentUserStream
- = std::unique_ptr<SvStream>(rStorage.OpenSotStream("Current User", StreamMode::STD_READ)))
+ tools::SvRef<SotStorageStream> pCurrentUserStream(rStorage.OpenSotStream("Current User", StreamMode::STD_READ));
+ if (pCurrentUserStream)
{
ReadPptCurrentUserAtom(*pCurrentUserStream, maParam.aCurrentUserAtom);
}
@@ -182,7 +182,8 @@ ImplSdPPTImport::ImplSdPPTImport( SdDrawDocument* pDocument, SotStorage& rStorag
{
sal_uLong nOldPos = rStCtrl.Tell();
- pStData = rStorage_.OpenSotStream( "Pictures", StreamMode::STD_READ );
+ mxPicturesStream = rStorage_.OpenSotStream( "Pictures", StreamMode::STD_READ );
+ pStData = mxPicturesStream.get();
rStCtrl.Seek( maDocHd.GetRecBegFilePos() + 8 );
sal_uLong nDocLen = maDocHd.GetRecEndFilePos();
@@ -218,7 +219,8 @@ ImplSdPPTImport::ImplSdPPTImport( SdDrawDocument* pDocument, SotStorage& rStorag
// Dtor
ImplSdPPTImport::~ImplSdPPTImport()
{
- delete pStData;
+ pStData = nullptr;
+ mxPicturesStream.clear();
}
// Import
diff --git a/sd/source/filter/ppt/pptin.hxx b/sd/source/filter/ppt/pptin.hxx
index 02c22e652350..f7bf91472e10 100644
--- a/sd/source/filter/ppt/pptin.hxx
+++ b/sd/source/filter/ppt/pptin.hxx
@@ -22,6 +22,7 @@
#include <filter/msfilter/svdfppt.hxx>
#include <diadef.h>
+#include <sot/storage.hxx>
#include <svx/svdtypes.hxx>
#include <memory>
@@ -43,6 +44,7 @@ typedef ::std::map < SdrObject*, Ppt97AnimationPtr > tAnimationMap;
class ImplSdPPTImport : public SdrPowerPointImport
{
+ tools::SvRef<SotStorageStream> mxPicturesStream;
SfxMedium& mrMed;
SotStorage& mrStorage;
DffRecordHeader maDocHd;
diff --git a/sd/source/filter/sdpptwrp.cxx b/sd/source/filter/sdpptwrp.cxx
index bf76d1c6df49..90f851e69fa4 100644
--- a/sd/source/filter/sdpptwrp.cxx
+++ b/sd/source/filter/sdpptwrp.cxx
@@ -186,7 +186,7 @@ bool SdPPTFilter::Import()
// Document is DRM encrypted
pStorage = lcl_DRMDecrypt(mrMedium, pStorage, aDecryptedStorageStrm);
}
- std::unique_ptr<SvStream> pDocStream(pStorage->OpenSotStream( "PowerPoint Document" , StreamMode::STD_READ ));
+ tools::SvRef<SotStorageStream> pDocStream(pStorage->OpenSotStream( "PowerPoint Document" , StreamMode::STD_READ ));
if( pDocStream )
{
pDocStream->SetVersion( pStorage->GetVersion() );