diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-12-24 12:58:02 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-12-28 15:42:24 +0100 |
commit | 3bd25d5087a376e4a2e7c0c6e3d2b9c37abd0a55 (patch) | |
tree | 3343e340f68c25b7e9134a3feefafd1d0964af94 | |
parent | cd966aac6ecd8ce606ac3f2ccd602e467114ba3f (diff) |
ofz#28912 Direct-leak in PPTStyleSheet::PPTStyleSheet
Change-Id: If6ee82bab1937599ee2908f9c610c63e505189ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108267
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | filter/source/msfilter/svdfppt.cxx | 72 | ||||
-rw-r--r-- | include/filter/msfilter/svdfppt.hxx | 6 |
2 files changed, 39 insertions, 39 deletions
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 4975ecfb2d2f..d89f4c3031f5 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -1627,7 +1627,7 @@ SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const O if ( aTxSIStyle.bValid && !aTxSIStyle.aList.empty() ) aTxSI = aTxSIStyle.aList[ 0 ]; - rE2.xStyleSheet.reset(new PPTStyleSheet(aSlideHd, rStCtrl, *this, aTxPFStyle, aTxSI)); + rE2.xStyleSheet = std::make_unique<PPTStyleSheet>(aSlideHd, rStCtrl, *this, aTxPFStyle, aTxSI); m_pDefaultSheet = rE2.xStyleSheet.get(); } if ( SeekToRec( rStCtrl, PPT_PST_ColorSchemeAtom, aSlideHd.GetRecEndFilePos() ) ) @@ -4091,18 +4091,18 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd sal_uInt32 nOldFilePos = rIn.Tell(); // default stylesheets - mpCharSheet[ TSS_Type::PageTitle ] = new PPTCharSheet( TSS_Type::PageTitle ); - mpCharSheet[ TSS_Type::Body ] = new PPTCharSheet( TSS_Type::Body ); - mpCharSheet[ TSS_Type::Notes ] = new PPTCharSheet( TSS_Type::Notes ); - mpCharSheet[ TSS_Type::Unused ] = new PPTCharSheet( TSS_Type::Unused ); // this entry is not used by ppt - mpCharSheet[ TSS_Type::TextInShape ] = new PPTCharSheet( TSS_Type::TextInShape ); - mpParaSheet[ TSS_Type::PageTitle ] = new PPTParaSheet( TSS_Type::PageTitle ); - mpParaSheet[ TSS_Type::Body ] = new PPTParaSheet( TSS_Type::Body ); - mpParaSheet[ TSS_Type::Notes ] = new PPTParaSheet( TSS_Type::Notes ); - mpParaSheet[ TSS_Type::Unused ] = new PPTParaSheet( TSS_Type::Unused ); - mpParaSheet[ TSS_Type::TextInShape ] = new PPTParaSheet( TSS_Type::TextInShape ); - mpCharSheet[ TSS_Type::QuarterBody ] = mpCharSheet[ TSS_Type::HalfBody ] = mpCharSheet[ TSS_Type::Title ] = mpCharSheet[ TSS_Type::Subtitle ] = nullptr; - mpParaSheet[ TSS_Type::QuarterBody ] = mpParaSheet[ TSS_Type::HalfBody ] = mpParaSheet[ TSS_Type::Title ] = mpParaSheet[ TSS_Type::Subtitle ] = nullptr; + mpCharSheet[ TSS_Type::PageTitle ] = std::make_unique<PPTCharSheet>( TSS_Type::PageTitle ); + mpCharSheet[ TSS_Type::Body ] = std::make_unique<PPTCharSheet>( TSS_Type::Body ); + mpCharSheet[ TSS_Type::Notes ] = std::make_unique<PPTCharSheet>( TSS_Type::Notes ); + mpCharSheet[ TSS_Type::Unused ] = std::make_unique<PPTCharSheet>( TSS_Type::Unused ); // this entry is not used by ppt + mpCharSheet[ TSS_Type::TextInShape ] = std::make_unique<PPTCharSheet>( TSS_Type::TextInShape ); + mpParaSheet[ TSS_Type::PageTitle ] = std::make_unique<PPTParaSheet>( TSS_Type::PageTitle ); + mpParaSheet[ TSS_Type::Body ] = std::make_unique<PPTParaSheet>( TSS_Type::Body ); + mpParaSheet[ TSS_Type::Notes ] = std::make_unique<PPTParaSheet>( TSS_Type::Notes ); + mpParaSheet[ TSS_Type::Unused ] = std::make_unique<PPTParaSheet>( TSS_Type::Unused ); + mpParaSheet[ TSS_Type::TextInShape ] = std::make_unique<PPTParaSheet>( TSS_Type::TextInShape ); + // mpCharSheet[ TSS_Type::QuarterBody ], mpCharSheet[ TSS_Type::HalfBody ], mpCharSheet[ TSS_Type::Title ], mpCharSheet[ TSS_Type::Subtitle ] intentionally null + // mpParaSheet[ TSS_Type::QuarterBody ], mpParaSheet[ TSS_Type::HalfBody ], mpParaSheet[ TSS_Type::Title ], mpParaSheet[ TSS_Type::Subtitle ] intentionally null /* SJ: try to locate the txMasterStyleAtom in the Environment @@ -4189,34 +4189,34 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd { if ( nInstance > TSS_Type::TextInShape ) { - delete mpCharSheet[ nInstance ]; // be sure to delete the old one if this instance comes twice - delete mpParaSheet[ nInstance ]; + mpCharSheet[ nInstance ].reset(); // be sure to delete the old one if this instance comes twice + mpParaSheet[ nInstance ].reset(); switch ( nInstance ) { case TSS_Type::Subtitle : { - mpCharSheet[ TSS_Type::Subtitle ] = new PPTCharSheet( *( mpCharSheet[ TSS_Type::Body ] ) ); - mpParaSheet[ TSS_Type::Subtitle ] = new PPTParaSheet( *( mpParaSheet[ TSS_Type::Body ] ) ); + mpCharSheet[ TSS_Type::Subtitle ] = std::make_unique<PPTCharSheet>( *( mpCharSheet[ TSS_Type::Body ] ) ); + mpParaSheet[ TSS_Type::Subtitle ] = std::make_unique<PPTParaSheet>( *( mpParaSheet[ TSS_Type::Body ] ) ); } break; case TSS_Type::Title : { - mpCharSheet[ TSS_Type::Title ] = new PPTCharSheet( *( mpCharSheet[ TSS_Type::PageTitle ] ) ); - mpParaSheet[ TSS_Type::Title ] = new PPTParaSheet( *( mpParaSheet[ TSS_Type::PageTitle ] ) ); + mpCharSheet[ TSS_Type::Title ] = std::make_unique<PPTCharSheet>( *( mpCharSheet[ TSS_Type::PageTitle ] ) ); + mpParaSheet[ TSS_Type::Title ] = std::make_unique<PPTParaSheet>( *( mpParaSheet[ TSS_Type::PageTitle ] ) ); } break; case TSS_Type::HalfBody : { - mpCharSheet[ TSS_Type::HalfBody ] = new PPTCharSheet( *( mpCharSheet[ TSS_Type::Body ] ) ); - mpParaSheet[ TSS_Type::HalfBody ] = new PPTParaSheet( *( mpParaSheet[ TSS_Type::Body ] ) ); + mpCharSheet[ TSS_Type::HalfBody ] = std::make_unique<PPTCharSheet>( *( mpCharSheet[ TSS_Type::Body ] ) ); + mpParaSheet[ TSS_Type::HalfBody ] = std::make_unique<PPTParaSheet>( *( mpParaSheet[ TSS_Type::Body ] ) ); } break; case TSS_Type::QuarterBody : { - mpCharSheet[ TSS_Type::QuarterBody ] = new PPTCharSheet( *( mpCharSheet[ TSS_Type::Body ] ) ); - mpParaSheet[ TSS_Type::QuarterBody ] = new PPTParaSheet( *( mpParaSheet[ TSS_Type::Body ] ) ); + mpCharSheet[ TSS_Type::QuarterBody ] = std::make_unique<PPTCharSheet>( *( mpCharSheet[ TSS_Type::Body ] ) ); + mpParaSheet[ TSS_Type::QuarterBody ] = std::make_unique<PPTParaSheet>( *( mpParaSheet[ TSS_Type::Body ] ) ); } break; default: break; @@ -4288,23 +4288,23 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd } if ( !mpCharSheet[ TSS_Type::Subtitle ] ) { - mpCharSheet[ TSS_Type::Subtitle ] = new PPTCharSheet( *( mpCharSheet[ TSS_Type::Body ] ) ); - mpParaSheet[ TSS_Type::Subtitle ] = new PPTParaSheet( *( mpParaSheet[ TSS_Type::Body ] ) ); + mpCharSheet[ TSS_Type::Subtitle ] = std::make_unique<PPTCharSheet>( *( mpCharSheet[ TSS_Type::Body ] ) ); + mpParaSheet[ TSS_Type::Subtitle ] = std::make_unique<PPTParaSheet>( *( mpParaSheet[ TSS_Type::Body ] ) ); } if ( !mpCharSheet[ TSS_Type::Title ] ) { - mpCharSheet[ TSS_Type::Title ] = new PPTCharSheet( *( mpCharSheet[ TSS_Type::PageTitle ] ) ); - mpParaSheet[ TSS_Type::Title ] = new PPTParaSheet( *( mpParaSheet[ TSS_Type::PageTitle ] ) ); + mpCharSheet[ TSS_Type::Title ] = std::make_unique<PPTCharSheet>( *( mpCharSheet[ TSS_Type::PageTitle ] ) ); + mpParaSheet[ TSS_Type::Title ] = std::make_unique<PPTParaSheet>( *( mpParaSheet[ TSS_Type::PageTitle ] ) ); } if ( !mpCharSheet[ TSS_Type::HalfBody ] ) { - mpCharSheet[ TSS_Type::HalfBody ] = new PPTCharSheet( *( mpCharSheet[ TSS_Type::Body ] ) ); - mpParaSheet[ TSS_Type::HalfBody ] = new PPTParaSheet( *( mpParaSheet[ TSS_Type::Body ] ) ); + mpCharSheet[ TSS_Type::HalfBody ] = std::make_unique<PPTCharSheet>( *( mpCharSheet[ TSS_Type::Body ] ) ); + mpParaSheet[ TSS_Type::HalfBody ] = std::make_unique<PPTParaSheet>( *( mpParaSheet[ TSS_Type::Body ] ) ); } if ( !mpCharSheet[ TSS_Type::QuarterBody ] ) { - mpCharSheet[ TSS_Type::QuarterBody ] = new PPTCharSheet( *( mpCharSheet[ TSS_Type::Body ] ) ); - mpParaSheet[ TSS_Type::QuarterBody ] = new PPTParaSheet( *( mpParaSheet[ TSS_Type::Body ] ) ); + mpCharSheet[ TSS_Type::QuarterBody ] = std::make_unique<PPTCharSheet>( *( mpCharSheet[ TSS_Type::Body ] ) ); + mpParaSheet[ TSS_Type::QuarterBody ] = std::make_unique<PPTParaSheet>( *( mpParaSheet[ TSS_Type::Body ] ) ); } if ( !bFoundTxMasterStyleAtom04 ) { // try to locate the txMasterStyleAtom in the Environment @@ -4412,7 +4412,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd aRule.SetLevel( nDepth, aNumberFormat ); } } - mpNumBulletItem[ i ] = new SvxNumBulletItem( aRule, EE_PARA_NUMBULLET ); + mpNumBulletItem[ i ] = std::make_unique<SvxNumBulletItem>( aRule, EE_PARA_NUMBULLET ); } } @@ -4420,9 +4420,9 @@ PPTStyleSheet::~PPTStyleSheet() { for ( auto i : o3tl::enumrange<TSS_Type>() ) { - delete mpCharSheet[ i ]; - delete mpParaSheet[ i ]; - delete mpNumBulletItem[ i ]; + mpCharSheet[i].reset(); + mpParaSheet[i].reset(); + mpNumBulletItem[i].reset(); } } @@ -6161,7 +6161,7 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet, std::optional< sal_Int16 >& rS if ( ( nDestinationInstance != TSS_Type::Unknown ) || ( mxParaSet->mnDepth <= 1 ) ) { - SvxNumBulletItem* pNumBulletItem = mrStyleSheet.mpNumBulletItem[ nInstance ]; + SvxNumBulletItem* pNumBulletItem = mrStyleSheet.mpNumBulletItem[ nInstance ].get(); if ( pNumBulletItem ) { SvxNumberFormat aNumberFormat( SVX_NUM_NUMBER_NONE ); diff --git a/include/filter/msfilter/svdfppt.hxx b/include/filter/msfilter/svdfppt.hxx index b1dc364d7d57..7bacc7763f92 100644 --- a/include/filter/msfilter/svdfppt.hxx +++ b/include/filter/msfilter/svdfppt.hxx @@ -849,9 +849,9 @@ class SvxNumBulletItem; struct PPTStyleSheet : public PPTNumberFormatCreator { PPTTextSpecInfo maTxSI; - o3tl::enumarray<TSS_Type, PPTCharSheet*> mpCharSheet; - o3tl::enumarray<TSS_Type, PPTParaSheet*> mpParaSheet; - o3tl::enumarray<TSS_Type, SvxNumBulletItem*> mpNumBulletItem; + o3tl::enumarray<TSS_Type, std::unique_ptr<PPTCharSheet>> mpCharSheet; + o3tl::enumarray<TSS_Type, std::unique_ptr<PPTParaSheet>> mpParaSheet; + o3tl::enumarray<TSS_Type, std::unique_ptr<SvxNumBulletItem>> mpNumBulletItem; PPTStyleSheet( const DffRecordHeader& rSlideHd, |