summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-11-10 12:53:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-11-11 06:55:41 +0000
commit78b4a1fb01af9ad3b3395a22f6e396be914b553e (patch)
tree846fdaea907a70fdc274a1e76642ed5e06622c0d /basctl
parent071e23fee07b92b8f07800cda3ca7e66afe818ae (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 'basctl')
-rw-r--r--basctl/source/basicide/basicrenderable.cxx6
-rw-r--r--basctl/source/basicide/baside2.cxx2
-rw-r--r--basctl/source/basicide/basides1.cxx16
-rw-r--r--basctl/source/basicide/basides2.cxx4
-rw-r--r--basctl/source/basicide/basides3.cxx4
-rw-r--r--basctl/source/basicide/basidesh.cxx4
-rw-r--r--basctl/source/basicide/basobj2.cxx2
-rw-r--r--basctl/source/basicide/basobj3.cxx4
-rw-r--r--basctl/source/basicide/localizationmgr.cxx2
9 files changed, 22 insertions, 22 deletions
diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx
index 4e5a9675b2c3..d1b7bced581d 100644
--- a/basctl/source/basicide/basicrenderable.cxx
+++ b/basctl/source/basicide/basicrenderable.cxx
@@ -93,7 +93,7 @@ sal_Int32 SAL_CALL Renderable::getRendererCount (
sal_Int32 nCount = 0;
if( mpWindow )
{
- if (Printer* pPrinter = getPrinter())
+ if (VclPtr<Printer> pPrinter = getPrinter())
{
nCount = mpWindow->countPages( pPrinter );
sal_Int64 nContent = getIntValue( "PrintContent", -1 );
@@ -124,7 +124,7 @@ Sequence<beans::PropertyValue> SAL_CALL Renderable::getRenderer (
Sequence< beans::PropertyValue > aVals;
// insert page size here
- Printer* pPrinter = getPrinter();
+ VclPtr<Printer> pPrinter = getPrinter();
// no renderdevice is legal; the first call is to get our print ui options
if( pPrinter )
{
@@ -152,7 +152,7 @@ void SAL_CALL Renderable::render (
if( mpWindow )
{
- if (Printer* pPrinter = getPrinter())
+ if (VclPtr<Printer> pPrinter = getPrinter())
{
sal_Int64 nContent = getIntValue( "PrintContent", -1 );
if( nContent == 1 )
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index 351ce03e34fd..0afd147228dc 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -617,7 +617,7 @@ bool ModulWindow::BasicErrorHdl( StarBASIC * pBasic )
ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
// #i47002#
- vcl::Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+ VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
if ( !pWindow )
return false;
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index 59c3006377ab..3f8f34c48624 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -320,7 +320,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
SfxViewFrame* pViewFrame = GetViewFrame();
if ( pViewFrame )
pViewFrame->ToTop();
- ModulWindow* pWin = FindBasWin( aDocument, aLibName, rInfo.GetModule(), true );
+ VclPtr<ModulWindow> pWin = FindBasWin( aDocument, aLibName, rInfo.GetModule(), true );
DBG_ASSERT( pWin, "Edit/Create Macro: Fenster wurde nicht erzeugt/gefunden!" );
SetCurWindow( pWin, true );
pWin->EditMacro( rInfo.GetMethod() );
@@ -344,13 +344,13 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
const SfxStringItem &rModName = static_cast<const SfxStringItem&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_MODULENAME ));
if ( aWindowTable.find( rTabId.GetValue() ) != aWindowTable.end() )
{
- BaseWindow* pWin = aWindowTable[ rTabId.GetValue() ];
+ VclPtr<BaseWindow> pWin = aWindowTable[ rTabId.GetValue() ];
const OUString& aNewName( rModName.GetValue() );
OUString aOldName( pWin->GetName() );
if ( aNewName != aOldName )
{
bool bRenameOk = false;
- if (ModulWindow* pModWin = dynamic_cast<ModulWindow*>(pWin))
+ if (ModulWindow* pModWin = dynamic_cast<ModulWindow*>(pWin.get()))
{
OUString aLibName = pModWin->GetLibName();
ScriptDocument aDocument( pWin->GetDocument() );
@@ -365,7 +365,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
}
}
- else if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(pWin))
+ else if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(pWin.get()))
{
bRenameOk = pDlgWin->RenameDialog( aNewName );
}
@@ -396,7 +396,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
BasicManager* pBasMgr = const_cast<BasicManager*>(rInfo.GetBasicManager());
DBG_ASSERT( pBasMgr, "Store source: Kein BasMgr?" );
ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
- ModulWindow* pWin = FindBasWin( aDocument, rInfo.GetLib(), rInfo.GetModule(), false, true );
+ VclPtr<ModulWindow> pWin = FindBasWin( aDocument, rInfo.GetLib(), rInfo.GetModule(), false, true );
if ( pWin )
{
if ( rReq.GetSlot() == SID_BASICIDE_STOREMODULESOURCE )
@@ -522,7 +522,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
const SbxItem& rSbxItem = static_cast<const SbxItem&>(rReq.GetArgs()->Get(SID_BASICIDE_ARG_SBX ));
const ScriptDocument& aDocument( rSbxItem.GetDocument() );
- BaseWindow* pWin = FindWindow( aDocument, rSbxItem.GetLibName(), rSbxItem.GetName(), rSbxItem.GetType(), true );
+ VclPtr<BaseWindow> pWin = FindWindow( aDocument, rSbxItem.GetLibName(), rSbxItem.GetName(), rSbxItem.GetType(), true );
if ( pWin )
RemoveWindow( pWin, true );
}
@@ -1103,7 +1103,7 @@ VclPtr<BaseWindow> Shell::FindWindow(
bool Shell::CallBasicErrorHdl( StarBASIC* pBasic )
{
bool bRet = false;
- ModulWindow* pModWin = ShowActiveModuleWindow( pBasic );
+ VclPtr<ModulWindow> pModWin = ShowActiveModuleWindow( pBasic );
if ( pModWin )
bRet = pModWin->BasicErrorHdl( pBasic );
return bRet;
@@ -1112,7 +1112,7 @@ bool Shell::CallBasicErrorHdl( StarBASIC* pBasic )
long Shell::CallBasicBreakHdl( StarBASIC* pBasic )
{
long nRet = 0;
- ModulWindow* pModWin = ShowActiveModuleWindow( pBasic );
+ VclPtr<ModulWindow> pModWin = ShowActiveModuleWindow( pBasic );
if ( pModWin )
{
bool bAppWindowDisabled, bDispatcherLocked;
diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx
index 40bd5c4bc327..378d4c551bb4 100644
--- a/basctl/source/basicide/basides2.cxx
+++ b/basctl/source/basicide/basides2.cxx
@@ -208,8 +208,8 @@ VclPtr<ModulWindow> Shell::FindBasWin (
bool bCreateIfNotExist, bool bFindSuspended
)
{
- if (BaseWindow* pWin = FindWindow(rDocument, rLibName, rName, TYPE_MODULE, bFindSuspended))
- return VclPtr<ModulWindow>(static_cast<ModulWindow*>(pWin));
+ if (VclPtr<BaseWindow> pWin = FindWindow(rDocument, rLibName, rName, TYPE_MODULE, bFindSuspended))
+ return VclPtr<ModulWindow>(static_cast<ModulWindow*>(pWin.get()));
return bCreateIfNotExist ? CreateBasWin(rDocument, rLibName, rName) : nullptr;
}
diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx
index f8458f67e385..218ef5772637 100644
--- a/basctl/source/basicide/basides3.cxx
+++ b/basctl/source/basicide/basides3.cxx
@@ -113,8 +113,8 @@ VclPtr<DialogWindow> Shell::FindDlgWin (
bool bCreateIfNotExist, bool bFindSuspended
)
{
- if (BaseWindow* pWin = FindWindow(rDocument, rLibName, rName, TYPE_DIALOG, bFindSuspended))
- return static_cast<DialogWindow*>(pWin);
+ if (VclPtr<BaseWindow> pWin = FindWindow(rDocument, rLibName, rName, TYPE_DIALOG, bFindSuspended))
+ return static_cast<DialogWindow*>(pWin.get());
return bCreateIfNotExist ? CreateDlgWin(rDocument, rLibName, rName) : nullptr;
}
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index 2cea9d1d8b0b..e24794bf7a37 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -458,7 +458,7 @@ bool Shell::NextPage( bool bPrev )
if ( nPos < pTabBar->GetPageCount() )
{
- BaseWindow* pWin = aWindowTable[ pTabBar->GetPageId( nPos ) ];
+ VclPtr<BaseWindow> pWin = aWindowTable[ pTabBar->GetPageId( nPos ) ];
SetCurWindow( pWin, true );
bRet = true;
}
@@ -682,7 +682,7 @@ void Shell::UpdateWindows()
for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
{
OUString aModName = pModNames[ j ];
- ModulWindow* pWin = FindBasWin( *doc, aLibName, aModName );
+ VclPtr<ModulWindow> pWin = FindBasWin( *doc, aLibName, aModName );
if ( !pWin )
pWin = CreateBasWin( *doc, aLibName, aModName );
if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aModName &&
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index 5d939a7134c0..b88a89f3b348 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -169,7 +169,7 @@ bool RenameModule (
if (Shell* pShell = GetShell())
{
- if (ModulWindow* pWin = pShell->FindBasWin(rDocument, rLibName, rNewName, false, true))
+ if (VclPtr<ModulWindow> pWin = pShell->FindBasWin(rDocument, rLibName, rNewName, false, true))
{
// set new name in window
pWin->SetName( rNewName );
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
index d406120b1d39..f3cdc49b6a70 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -158,7 +158,7 @@ bool RenameDialog (
}
Shell* pShell = GetShell();
- DialogWindow* pWin = pShell ? pShell->FindDlgWin(rDocument, rLibName, rOldName) : nullptr;
+ VclPtr<DialogWindow> pWin = pShell ? pShell->FindDlgWin(rDocument, rLibName, rOldName) : nullptr;
Reference< XNameContainer > xExistingDialog;
if ( pWin )
xExistingDialog = pWin->GetEditor().GetDialog();
@@ -195,7 +195,7 @@ bool RemoveDialog( const ScriptDocument& rDocument, const OUString& rLibName, co
{
if (Shell* pShell = GetShell())
{
- if (DialogWindow* pDlgWin = pShell->FindDlgWin(rDocument, rLibName, rDlgName))
+ if (VclPtr<DialogWindow> pDlgWin = pShell->FindDlgWin(rDocument, rLibName, rDlgName))
{
Reference< container::XNameContainer > xDialogModel = pDlgWin->GetDialog();
LocalizationMgr::removeResourceForDialog( rDocument, rLibName, rDlgName, xDialogModel );
diff --git a/basctl/source/basicide/localizationmgr.cxx b/basctl/source/basicide/localizationmgr.cxx
index 6ee7bdd752d8..decf6d48f565 100644
--- a/basctl/source/basicide/localizationmgr.cxx
+++ b/basctl/source/basicide/localizationmgr.cxx
@@ -136,7 +136,7 @@ void LocalizationMgr::implEnableDisableResourceForAllLibraryDialogs( HandleResou
for( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
{
OUString aDlgName = pDlgNames[ i ];
- if (DialogWindow* pWin = m_pShell->FindDlgWin(m_aDocument, m_aLibName, aDlgName))
+ if (VclPtr<DialogWindow> pWin = m_pShell->FindDlgWin(m_aDocument, m_aLibName, aDlgName))
{
Reference< container::XNameContainer > xDialog = pWin->GetDialog();
if( xDialog.is() )