diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-10 12:53:02 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-11 06:55:41 +0000 |
commit | 78b4a1fb01af9ad3b3395a22f6e396be914b553e (patch) | |
tree | 846fdaea907a70fdc274a1e76642ed5e06622c0d /svx | |
parent | add move operators for VclPtr (diff) | |
download | core-78b4a1fb01af9ad3b3395a22f6e396be914b553e.tar.gz core-78b4a1fb01af9ad3b3395a22f6e396be914b553e.zip |
update vclwidget loplugin to find ref-dropping assigment
Look for places where we are accidentally assigning a returned-by-value
VclPtr<T> to a T*, which generally ends up in a use-after-free.
Change-Id: I4f361eaca88820cdb7aa3b8340212db61580fdd9
Reviewed-on: https://gerrit.libreoffice.org/30749
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/accessibility/AccessibleSvxFindReplaceDialog.cxx | 4 | ||||
-rw-r--r-- | svx/source/fmcomp/fmgridif.cxx | 12 | ||||
-rw-r--r-- | svx/source/fmcomp/gridctrl.cxx | 2 | ||||
-rw-r--r-- | svx/source/gallery2/galbrws1.cxx | 2 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx | 4 | ||||
-rw-r--r-- | svx/source/sidebar/PanelFactory.cxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/grafctrl.cxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/linectrl.cxx | 3 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 4 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunocontroller.cxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbunosearchcontrollers.cxx | 32 |
11 files changed, 33 insertions, 36 deletions
diff --git a/svx/source/accessibility/AccessibleSvxFindReplaceDialog.cxx b/svx/source/accessibility/AccessibleSvxFindReplaceDialog.cxx index aafb7df1bb73..2430b5420b7b 100644 --- a/svx/source/accessibility/AccessibleSvxFindReplaceDialog.cxx +++ b/svx/source/accessibility/AccessibleSvxFindReplaceDialog.cxx @@ -39,10 +39,10 @@ VCLXAccessibleSvxFindReplaceDialog::~VCLXAccessibleSvxFindReplaceDialog() void VCLXAccessibleSvxFindReplaceDialog::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) { VCLXAccessibleComponent::FillAccessibleRelationSet( rRelationSet ); - vcl::Window* pDlg = GetWindow(); + VclPtr<vcl::Window> pDlg = GetWindow(); if ( pDlg ) { - SvxSearchDialog* pSrchDlg = static_cast<SvxSearchDialog*>( pDlg ); + SvxSearchDialog* pSrchDlg = static_cast<SvxSearchDialog*>( pDlg.get() ); vcl::Window* pDocWin = pSrchDlg->GetDocWin(); if ( !pDocWin ) { diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index c940c1435559..936b4f6fe924 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -1060,7 +1060,7 @@ VclPtr<FmGridControl> FmXGridPeer::imp_CreateControl(vcl::Window* pParent, WinBi void FmXGridPeer::Create(vcl::Window* pParent, WinBits nStyle) { - FmGridControl* pWin = imp_CreateControl(pParent, nStyle); + VclPtr<FmGridControl> pWin = imp_CreateControl(pParent, nStyle); DBG_ASSERT(pWin != nullptr, "FmXGridPeer::Create : imp_CreateControl didn't return a control !"); pWin->SetStateProvider(LINK(this, FmXGridPeer, OnQueryGridSlotState)); @@ -1693,9 +1693,9 @@ void FmXGridPeer::setDesignMode(sal_Bool bOn) throw( RuntimeException, std::exce { if (bOn != isDesignMode()) { - vcl::Window* pWin = GetWindow(); + VclPtr<vcl::Window> pWin = GetWindow(); if (pWin) - static_cast<FmGridControl*>(pWin)->SetDesignMode(bOn); + static_cast<FmGridControl*>(pWin.get())->SetDesignMode(bOn); } if (bOn) @@ -1707,9 +1707,9 @@ void FmXGridPeer::setDesignMode(sal_Bool bOn) throw( RuntimeException, std::exce sal_Bool FmXGridPeer::isDesignMode() throw( RuntimeException, std::exception ) { - vcl::Window* pWin = GetWindow(); + VclPtr<vcl::Window> pWin = GetWindow(); if (pWin) - return static_cast<FmGridControl*>(pWin)->IsDesignMode(); + return static_cast<FmGridControl*>(pWin.get())->IsDesignMode(); else return false; } @@ -2007,7 +2007,7 @@ Reference< XAccessibleContext > FmXGridPeer::CreateAccessibleContext() Reference< XAccessibleContext > xContext; // use the AccessibleContext provided by the VCL window - vcl::Window* pGrid = GetWindow(); + VclPtr<vcl::Window> pGrid = GetWindow(); if ( pGrid ) { Reference< XAccessible > xAcc( pGrid->GetAccessible() ); diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index b6e46a863074..9457839c1c70 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -991,7 +991,7 @@ void DbGridControl::InsertHandleColumn() void DbGridControl::Init() { - BrowserHeader* pNewHeader = CreateHeaderBar(this); + VclPtr<BrowserHeader> pNewHeader = CreateHeaderBar(this); pHeader->SetMouseTransparent(false); SetHeaderBar(pNewHeader); diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx index 56028365e36a..dbd09be8f738 100644 --- a/svx/source/gallery2/galbrws1.cxx +++ b/svx/source/gallery2/galbrws1.cxx @@ -265,7 +265,7 @@ void GalleryBrowser1::ImplGalleryThemeProperties( const OUString & rThemeName, b SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); assert(pFact && "Got no AbstractDialogFactory!"); - VclAbstractDialog2* pThemeProps = pFact->CreateGalleryThemePropertiesDialog( mpExchangeData, mpThemePropsDlgItemSet ); + VclPtr<VclAbstractDialog2> pThemeProps = pFact->CreateGalleryThemePropertiesDialog( mpExchangeData, mpThemePropsDlgItemSet ); assert(pThemeProps && "Got no GalleryThemePropertiesDialog!"); if ( bCreateNew ) diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx index 06009352fa80..2e6792b713b4 100644 --- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx @@ -253,7 +253,7 @@ namespace sdr { namespace contact { Reference< XWindowPeer > xPeer( m_xControl->getPeer() ); if ( xPeer.is() ) { - vcl::Window* pWindow = VCLUnoHelper::GetWindow( xPeer ); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xPeer ); OSL_ENSURE( pWindow, "ControlHolder::invalidate: no implementation access!" ); if ( pWindow ) pWindow->Invalidate(); @@ -266,7 +266,7 @@ namespace sdr { namespace contact { // no check whether we're valid, this is the responsibility of the caller // Argh. Why does XView have a setZoom only, but not a getZoom? - vcl::Window* pWindow = VCLUnoHelper::GetWindow( m_xControl->getPeer() ); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( m_xControl->getPeer() ); OSL_ENSURE( pWindow, "ControlHolder::getZoom: no implementation access!" ); ::basegfx::B2DVector aZoom( 1, 1 ); diff --git a/svx/source/sidebar/PanelFactory.cxx b/svx/source/sidebar/PanelFactory.cxx index 574145b8c43b..664586e1789e 100644 --- a/svx/source/sidebar/PanelFactory.cxx +++ b/svx/source/sidebar/PanelFactory.cxx @@ -120,7 +120,7 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement ( aArguments.getOrDefault("ApplicationName", OUString()), aArguments.getOrDefault("ContextName", OUString())); - vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); + VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); if ( ! xParentWindow.is() || pParentWindow==nullptr) throw RuntimeException( "PanelFactory::createUIElement called without ParentWindow", diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx index 22cc91850634..114f23f0fe03 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -710,7 +710,7 @@ void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView ) assert(pFact && "Dialog creation failed!"); ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_GRFCROP ); assert(fnCreatePage && "Dialog creation failed!"); - SfxTabPage* pTabPage = (*fnCreatePage)( aCropDialog->get_content_area(), &aCropDlgAttr ); + VclPtr<SfxTabPage> pTabPage = (*fnCreatePage)( aCropDialog->get_content_area(), &aCropDlgAttr ); pTabPage->SetText( aCropStr ); aCropDialog->SetTabPage( pTabPage ); diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx index 98d3ffbaede0..3e7316647d66 100644 --- a/svx/source/tbxctrls/linectrl.cxx +++ b/svx/source/tbxctrls/linectrl.cxx @@ -570,8 +570,7 @@ SvxLineEndToolBoxControl::~SvxLineEndToolBoxControl() VclPtr<SfxPopupWindow> SvxLineEndToolBoxControl::CreatePopupWindow() { - SvxLineEndWindow* pLineEndWin = - VclPtr<SvxLineEndWindow>::Create( GetId(), m_xFrame, &GetToolBox(), SVX_RESSTR( RID_SVXSTR_LINEEND ) ); + VclPtrInstance<SvxLineEndWindow> pLineEndWin( GetId(), m_xFrame, &GetToolBox(), SVX_RESSTR( RID_SVXSTR_LINEEND ) ); pLineEndWin->StartPopupMode( &GetToolBox(), FloatWinPopupFlags::GrabFocus | FloatWinPopupFlags::AllowTearOff | diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index c5c0d568227c..f774559ab0c1 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -2822,9 +2822,7 @@ void SvxColorToolBoxControl::setColorSelectFunction(const ColorSelectFunction& a VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow() { - SvxColorWindow* pColorWin = - VclPtr<SvxColorWindow>::Create( - + VclPtrInstance<SvxColorWindow> pColorWin( m_aCommandURL, m_aPaletteManager, m_aBorderColorStatus, diff --git a/svx/source/tbxctrls/tbunocontroller.cxx b/svx/source/tbxctrls/tbunocontroller.cxx index c6fc28f4a469..c7e74bd51c37 100644 --- a/svx/source/tbxctrls/tbunocontroller.cxx +++ b/svx/source/tbxctrls/tbunocontroller.cxx @@ -385,7 +385,7 @@ uno::Reference< awt::XWindow > SAL_CALL FontHeightToolBoxControl::createItemWind { uno::Reference< awt::XWindow > xItemWindow; - vcl::Window* pParent = VCLUnoHelper::GetWindow( xParent ); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xParent ); if ( pParent ) { SolarMutexGuard aSolarMutexGuard; diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 9628b8b952e6..b411c6cf18b2 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -430,8 +430,8 @@ void SAL_CALL FindTextToolbarController::initialize( const css::uno::Sequence< c { svt::ToolboxController::initialize(aArguments); - vcl::Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); - ToolBox* pToolBox = static_cast<ToolBox*>(pWindow); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = static_cast<ToolBox*>(pWindow.get()); if ( pToolBox ) { sal_uInt16 nItemCount = pToolBox->GetItemCount(); @@ -452,10 +452,10 @@ css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::cre { css::uno::Reference< css::awt::XWindow > xItemWindow; - vcl::Window* pParent = VCLUnoHelper::GetWindow( xParent ); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xParent ); if ( pParent ) { - ToolBox* pToolbar = static_cast<ToolBox*>(pParent); + ToolBox* pToolbar = static_cast<ToolBox*>(pParent.get()); m_pFindTextFieldControl = VclPtr<FindTextFieldControl>::Create( pToolbar, WinBits( WB_DROPDOWN | WB_VSCROLL), m_xFrame, m_xContext ); Size aSize(250, m_pFindTextFieldControl->GetTextHeight() + 200); @@ -491,8 +491,8 @@ IMPL_LINK_NOARG(FindTextToolbarController, EditModifyHdl, Edit&, void) void FindTextToolbarController::textfieldChanged() { // enable or disable item DownSearch/UpSearch of findbar - vcl::Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); - ToolBox* pToolBox = static_cast<ToolBox*>(pWindow); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = static_cast<ToolBox*>(pWindow.get()); if ( pToolBox && m_pFindTextFieldControl ) { bool enableButtons = !m_pFindTextFieldControl->GetText().isEmpty(); @@ -575,8 +575,8 @@ void SAL_CALL UpDownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ if ( m_bDisposed ) throw css::lang::DisposedException(); - vcl::Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); - ToolBox* pToolBox = static_cast<ToolBox*>(pWindow); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = static_cast<ToolBox*>(pWindow.get()); impl_executeSearch(m_xContext, m_xFrame, pToolBox, meType == UP ); @@ -665,10 +665,10 @@ css::uno::Reference< css::awt::XWindow > SAL_CALL MatchCaseToolboxController::cr { css::uno::Reference< css::awt::XWindow > xItemWindow; - vcl::Window* pParent = VCLUnoHelper::GetWindow( xParent ); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xParent ); if ( pParent ) { - ToolBox* pToolbar = static_cast<ToolBox*>(pParent); + ToolBox* pToolbar = static_cast<ToolBox*>(pParent.get()); m_pMatchCaseControl = VclPtr<CheckBox>::Create( pToolbar, 0 ); m_pMatchCaseControl->SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_MATCHCASE ) ); Size aSize( m_pMatchCaseControl->GetOptimalSize() ); @@ -757,10 +757,10 @@ css::uno::Reference< css::awt::XWindow > SAL_CALL SearchFormattedToolboxControll { css::uno::Reference< css::awt::XWindow > xItemWindow; - vcl::Window* pParent = VCLUnoHelper::GetWindow( xParent ); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xParent ); if ( pParent ) { - ToolBox* pToolbar = static_cast<ToolBox*>(pParent); + ToolBox* pToolbar = static_cast<ToolBox*>(pParent.get()); m_pSearchFormattedControl = VclPtr<CheckBox>::Create( pToolbar, 0 ); m_pSearchFormattedControl->SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_SEARCHFORMATTED ) ); Size aSize( m_pSearchFormattedControl->GetOptimalSize() ); @@ -848,8 +848,8 @@ void SAL_CALL FindAllToolboxController::execute( sal_Int16 /*KeyModifier*/ ) thr if ( m_bDisposed ) throw css::lang::DisposedException(); - vcl::Window* pWindow = VCLUnoHelper::GetWindow( getParent() ); - ToolBox* pToolBox = static_cast<ToolBox*>(pWindow); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( getParent() ); + ToolBox* pToolBox = static_cast<ToolBox*>(pWindow.get()); impl_executeSearch(m_xContext, m_xFrame, pToolBox, false, true); } @@ -1142,8 +1142,8 @@ void SAL_CALL FindbarDispatcher::dispatch( const css::util::URL& aURL, const css } css::uno::Reference< css::awt::XWindow > xWindow(xUIElement->getRealInterface(), css::uno::UNO_QUERY); - vcl::Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); - ToolBox* pToolBox = static_cast<ToolBox*>(pWindow); + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); + ToolBox* pToolBox = static_cast<ToolBox*>(pWindow.get()); if ( pToolBox ) { sal_uInt16 nItemCount = pToolBox->GetItemCount(); |