summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-09-06 20:09:34 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-09-07 16:46:57 +0200
commit86b55d24940b476162c1a9d218082fbe9a0bf1e1 (patch)
tree75943b0ac5e2f7c97fd8e0aa8760c40166c5aa00
parentc24fe44064c6624fefe642508086c8562c372fba (diff)
cid#1500419 rearrange to silence Use after free
Change-Id: I4529306d94c88ba6572f108f512f1521c849246c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139536 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--filter/source/msfilter/escherex.cxx7
-rw-r--r--include/filter/msfilter/escherex.hxx4
-rw-r--r--oox/source/export/vmlexport.cxx2
-rw-r--r--sw/source/filter/ww8/rtfsdrexport.cxx6
4 files changed, 5 insertions, 14 deletions
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 3044762de92a..9c754b236988 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -4867,7 +4867,6 @@ public:
EscherEx::EscherEx(std::shared_ptr<EscherExGlobal> xGlobal, SvStream* pOutStrm, bool bOOXML)
: mxGlobal(std::move(xGlobal))
, mpOutStrm(pOutStrm)
- , mbOwnsStrm(false)
, mnCurrentDg(0)
, mnCountOfs(0)
, mnGroupLevel(0)
@@ -4878,8 +4877,8 @@ EscherEx::EscherEx(std::shared_ptr<EscherExGlobal> xGlobal, SvStream* pOutStrm,
{
if (!mpOutStrm)
{
- mpOutStrm = new SvNullStream();
- mbOwnsStrm = true;
+ mxOwnStrm = std::make_unique<SvNullStream>();
+ mpOutStrm = mxOwnStrm.get();
}
mnStrmStartOfs = mpOutStrm->Tell();
mpImplEESdrWriter.reset( new ImplEESdrWriter( *this ) );
@@ -4887,8 +4886,6 @@ EscherEx::EscherEx(std::shared_ptr<EscherExGlobal> xGlobal, SvStream* pOutStrm,
EscherEx::~EscherEx()
{
- if (mbOwnsStrm)
- delete mpOutStrm;
}
void EscherEx::Flush( SvStream* pPicStreamMergeBSE /* = NULL */ )
diff --git a/include/filter/msfilter/escherex.hxx b/include/filter/msfilter/escherex.hxx
index ac6b4cc004a3..f6906173ee1a 100644
--- a/include/filter/msfilter/escherex.hxx
+++ b/include/filter/msfilter/escherex.hxx
@@ -1048,9 +1048,9 @@ class MSFILTER_DLLPUBLIC EscherEx : public EscherPersistTable
{
protected:
std::shared_ptr<EscherExGlobal> mxGlobal;
- ::std::unique_ptr< ImplEESdrWriter > mpImplEESdrWriter;
+ std::unique_ptr<ImplEESdrWriter> mpImplEESdrWriter;
+ std::unique_ptr<SvStream> mxOwnStrm;
SvStream* mpOutStrm;
- bool mbOwnsStrm;
sal_uInt32 mnStrmStartOfs;
std::vector< sal_uInt32 > mOffsets;
std::vector< sal_uInt16 > mRecTypes;
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 8f9269db0de3..fa21068cf4b6 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -89,8 +89,6 @@ void VMLExport::SetFS( const ::sax_fastparser::FSHelperPtr& pSerializer )
VMLExport::~VMLExport()
{
- delete mpOutStrm;
- mpOutStrm = nullptr;
}
void VMLExport::OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance )
diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx
index 6b41e7ce044e..2820aa68eb89 100644
--- a/sw/source/filter/ww8/rtfsdrexport.cxx
+++ b/sw/source/filter/ww8/rtfsdrexport.cxx
@@ -56,11 +56,7 @@ RtfSdrExport::RtfSdrExport(RtfExport& rExport)
memset(m_pShapeTypeWritten.get(), 0, ESCHER_ShpInst_COUNT * sizeof(bool));
}
-RtfSdrExport::~RtfSdrExport()
-{
- delete mpOutStrm;
- mpOutStrm = nullptr;
-}
+RtfSdrExport::~RtfSdrExport() {}
void RtfSdrExport::OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance)
{