filter/source/msfilter/escherex.cxx | 7 ++----- include/filter/msfilter/escherex.hxx | 4 ++-- oox/source/export/vmlexport.cxx | 2 -- sw/source/filter/ww8/rtfsdrexport.cxx | 6 +----- 4 files changed, 5 insertions(+), 14 deletions(-)
New commits: commit 86b55d24940b476162c1a9d218082fbe9a0bf1e1 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Sep 6 20:09:34 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Sep 7 16:46:57 2022 +0200 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 <caol...@redhat.com> 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) {