From 78b4a1fb01af9ad3b3395a22f6e396be914b553e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 10 Nov 2016 12:53:02 +0200 Subject: update vclwidget loplugin to find ref-dropping assigment Look for places where we are accidentally assigning a returned-by-value VclPtr 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 Reviewed-by: Noel Grandin --- sfx2/source/dialog/backingcomp.cxx | 6 +++--- sfx2/source/dialog/dockwin.cxx | 2 +- sfx2/source/dialog/mailmodel.cxx | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sfx2/source/dialog') diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index 43f018de78b5..0e53109a83d3 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -700,7 +700,7 @@ void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno } // create the component window - vcl::Window* pParent = VCLUnoHelper::GetWindow(xParentWindow); + VclPtr pParent = VCLUnoHelper::GetWindow(xParentWindow); VclPtr pWindow = VclPtr::Create(pParent); m_xWindow = VCLUnoHelper::GetInterface(pWindow); @@ -772,8 +772,8 @@ void SAL_CALL BackingComp::dispatch( const css::util::URL& aURL, const css::uno: // vnd.org.libreoffice.recentdocs:ClearRecentFileList - clear recent files if ( aURL.Path == "ClearRecentFileList" ) { - vcl::Window* pWindow = VCLUnoHelper::GetWindow(m_xWindow); - BackingWindow* pBack = dynamic_cast(pWindow ); + VclPtr pWindow = VCLUnoHelper::GetWindow(m_xWindow); + BackingWindow* pBack = dynamic_cast(pWindow.get()); if( pBack ) { pBack->clearRecentFileList(); diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx index 76c41d2ac048..a51397d07906 100644 --- a/sfx2/source/dialog/dockwin.cxx +++ b/sfx2/source/dialog/dockwin.cxx @@ -197,7 +197,7 @@ SfxDockingWrapper::SfxDockingWrapper( vcl::Window* pParentWnd , { } - vcl::Window* pContentWindow = VCLUnoHelper::GetWindow(xWindow); + VclPtr pContentWindow = VCLUnoHelper::GetWindow(xWindow); if ( pContentWindow ) pContentWindow->SetStyle( pContentWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL ); pTitleDockWindow->SetWrappedWindow(pContentWindow); diff --git a/sfx2/source/dialog/mailmodel.cxx b/sfx2/source/dialog/mailmodel.cxx index e9bc1be90f0e..d7d2b55d3984 100644 --- a/sfx2/source/dialog/mailmodel.cxx +++ b/sfx2/source/dialog/mailmodel.cxx @@ -821,7 +821,7 @@ SfxMailModel::SendMailResult SfxMailModel::Send( const css::uno::Reference< css: css::uno::Reference< css::awt::XWindow > xParentWindow = xFrame->getContainerWindow(); SolarMutexGuard aGuard; - vcl::Window* pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); + VclPtr pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); ScopedVclPtrInstance< MessageDialog > aBox(pParentWindow, "ErrorFindEmailDialog", "sfx/ui/errorfindemaildialog.ui"); aBox->Execute(); -- cgit