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 /sw | |
parent | 071e23fee07b92b8f07800cda3ca7e66afe818ae (diff) |
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 'sw')
-rw-r--r-- | sw/source/ui/chrdlg/tblnumfm.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/dialog/addrdlg.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/frmdlg/uiborder.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mailmergehelper.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/SwPanelFactory.cxx | 2 |
7 files changed, 13 insertions, 14 deletions
diff --git a/sw/source/ui/chrdlg/tblnumfm.cxx b/sw/source/ui/chrdlg/tblnumfm.cxx index 108b6b3eb19c..5220ee5c53a3 100644 --- a/sw/source/ui/chrdlg/tblnumfm.cxx +++ b/sw/source/ui/chrdlg/tblnumfm.cxx @@ -40,7 +40,7 @@ SwNumFormatDlg::SwNumFormatDlg(vcl::Window* pParent, const SfxItemSet& rSet) if ( fnCreatePage ) { - SfxTabPage* pNewPage = (*fnCreatePage)( get_content_area(), &rSet ); + VclPtr<SfxTabPage> pNewPage = (*fnCreatePage)( get_content_area(), &rSet ); SfxAllItemSet aSet(*(rSet.GetPool())); aSet.Put ( SvxNumberInfoItem( static_cast<const SvxNumberInfoItem&>(pNewPage->GetItemSet().Get( SID_ATTR_NUMBERFORMAT_INFO )))); pNewPage->PageCreated(aSet); diff --git a/sw/source/ui/dialog/addrdlg.cxx b/sw/source/ui/dialog/addrdlg.cxx index 2370e35a6c4d..a4d57570ba45 100644 --- a/sw/source/ui/dialog/addrdlg.cxx +++ b/sw/source/ui/dialog/addrdlg.cxx @@ -29,7 +29,7 @@ SwAddrDlg::SwAddrDlg(vcl::Window* pParent, const SfxItemSet& rSet) ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SFXPAGE_GENERAL ); if ( fnCreatePage ) { - SfxTabPage* pPage2 = (*fnCreatePage)(get_content_area(), &rSet); + VclPtr<SfxTabPage> pPage2 = (*fnCreatePage)(get_content_area(), &rSet); SetTabPage(pPage2); } } diff --git a/sw/source/ui/frmdlg/uiborder.cxx b/sw/source/ui/frmdlg/uiborder.cxx index 5108a122832f..0b9e07793b0a 100644 --- a/sw/source/ui/frmdlg/uiborder.cxx +++ b/sw/source/ui/frmdlg/uiborder.cxx @@ -41,7 +41,7 @@ SwBorderDlg::SwBorderDlg(vcl::Window* pParent, SfxItemSet& rSet, SwBorderModes n if ( fnCreatePage ) { - SfxTabPage* pNewPage = (*fnCreatePage)( get_content_area(), &rSet ); + VclPtr<SfxTabPage> pNewPage = (*fnCreatePage)( get_content_area(), &rSet ); SfxAllItemSet aSet(*(rSet.GetPool())); aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE, static_cast<sal_uInt16>(nType))); if(SwBorderModes::TABLE == nType) diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 57a62d38c37b..5e7fb3496947 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -2873,7 +2873,7 @@ Control* SwTokenWindow::InsertItem(const OUString& rText, const SwFormToken& if(!aControlList.empty()) { - Control* pLast = *(aControlList.rbegin()); + Control* pLast = aControlList.rbegin()->get(); aControlSize = pLast->GetSizePixel(); aControlPos = pLast->GetPosPixel(); @@ -3230,8 +3230,8 @@ void SwTokenWindow::AdjustScrolling() if(aControlList.size() > 1) { //validate scroll buttons - Control* pFirstCtrl = *(aControlList.begin()); - Control* pLastCtrl = *(aControlList.rbegin()); + Control* pFirstCtrl = aControlList.begin()->get(); + Control* pLastCtrl = aControlList.rbegin()->get(); long nSpace = m_pCtrlParentWin->GetSizePixel().Width(); long nWidth = pLastCtrl->GetPosPixel().X() - pFirstCtrl->GetPosPixel().X() @@ -3551,7 +3551,7 @@ void SwTokenWindow::GetFocus() { if (!aControlList.empty()) { - Control *pFirst = *aControlList.begin(); + Control *pFirst = aControlList.begin()->get(); if (pFirst) { diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx index 9910fe0756f8..2ba1b834fa9b 100644 --- a/sw/source/uibase/dbui/mailmergehelper.cxx +++ b/sw/source/uibase/dbui/mailmergehelper.cxx @@ -613,8 +613,7 @@ OUString SwAuthenticator::getPassword( ) throw (RuntimeException, std::exceptio { if(!m_aUserName.isEmpty() && m_aPassword.isEmpty() && m_pParentWindow) { - SfxPasswordDialog* pPasswdDlg = - VclPtr<SfxPasswordDialog>::Create( m_pParentWindow ); + ScopedVclPtrInstance<SfxPasswordDialog> pPasswdDlg( m_pParentWindow ); pPasswdDlg->SetMinLen( 0 ); if(RET_OK == pPasswdDlg->Execute()) m_aPassword = pPasswdDlg->GetPassword(); diff --git a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx index e119d5f790ce..c2783bb3acc0 100644 --- a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx +++ b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx @@ -176,8 +176,8 @@ void MMCurrentEntryController::dispose() throw (uno::RuntimeException, std::exce uno::Reference<awt::XWindow> MMCurrentEntryController::createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception) { - vcl::Window* pParent = VCLUnoHelper::GetWindow(rParent); - ToolBox* pToolbar = dynamic_cast<ToolBox*>(pParent); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(rParent); + ToolBox* pToolbar = dynamic_cast<ToolBox*>(pParent.get()); if (pToolbar) { // make it visible @@ -247,8 +247,8 @@ void MMExcludeEntryController::dispose() throw (uno::RuntimeException, std::exce uno::Reference<awt::XWindow> MMExcludeEntryController::createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception) { - vcl::Window* pParent = VCLUnoHelper::GetWindow(rParent); - ToolBox* pToolbar = dynamic_cast<ToolBox*>(pParent); + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(rParent); + ToolBox* pToolbar = dynamic_cast<ToolBox*>(pParent.get()); if (pToolbar) { // make it visible diff --git a/sw/source/uibase/sidebar/SwPanelFactory.cxx b/sw/source/uibase/sidebar/SwPanelFactory.cxx index 985000c491f5..d1d85d1d5f22 100644 --- a/sw/source/uibase/sidebar/SwPanelFactory.cxx +++ b/sw/source/uibase/sidebar/SwPanelFactory.cxx @@ -109,7 +109,7 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement ( const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0))); SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue); - 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", |