summaryrefslogtreecommitdiff
path: root/basic/source/runtime
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-05-29 09:27:30 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-05-29 09:29:15 +0900
commita71ae24a236aa7bf6c17cad92a1662e63b7a13bf (patch)
tree64a0298f173c4b05f525e1288d9c28fa563dc899 /basic/source/runtime
parent7c8b2f10310f0f64b111afb3012e82e9c4a690ac (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: Iac63a5d60478e5cd8e2b77c889c7b312d3d15f67
Diffstat (limited to 'basic/source/runtime')
-rw-r--r--basic/source/runtime/inputbox.cxx6
-rw-r--r--basic/source/runtime/methods.cxx19
2 files changed, 12 insertions, 13 deletions
diff --git a/basic/source/runtime/inputbox.cxx b/basic/source/runtime/inputbox.cxx
index 152d625e46f7..bec0dfbfa666 100644
--- a/basic/source/runtime/inputbox.cxx
+++ b/basic/source/runtime/inputbox.cxx
@@ -26,6 +26,7 @@
#include "runtime.hxx"
#include "stdobj.hxx"
#include "rtlproto.hxx"
+#include <boost/scoped_ptr.hpp>
class SvRTLInputBox : public ModalDialog
{
@@ -171,11 +172,10 @@ RTLFUNC(InputBox)
nX = rPar.Get(4)->GetLong();
nY = rPar.Get(5)->GetLong();
}
- SvRTLInputBox *pDlg=new SvRTLInputBox(GetpApp()->GetDefDialogParent(),
- rPrompt,aTitle,aDefault,nX,nY);
+ boost::scoped_ptr<SvRTLInputBox> pDlg(new SvRTLInputBox(GetpApp()->GetDefDialogParent(),
+ rPrompt,aTitle,aDefault,nX,nY));
pDlg->Execute();
rPar.Get(0)->PutString( pDlg->GetText() );
- delete pDlg;
}
}
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 2e3c375699b2..02d51db51f92 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -57,6 +57,7 @@
#include <ooo/vba/XHelperInterface.hpp>
#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
#include <boost/scoped_array.hpp>
+#include <boost/scoped_ptr.hpp>
using namespace comphelper;
using namespace osl;
@@ -4475,8 +4476,8 @@ RTLFUNC(LoadPicture)
}
OUString aFileURL = getFullPath( rPar.Get(1)->GetOUString() );
- SvStream* pStream = utl::UcbStreamHelper::CreateStream( aFileURL, STREAM_READ );
- if( pStream != NULL )
+ boost::scoped_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream( aFileURL, STREAM_READ ));
+ if( pStream )
{
Bitmap aBmp;
ReadDIB(aBmp, *pStream, true);
@@ -4486,7 +4487,6 @@ RTLFUNC(LoadPicture)
((SbStdPicture*)(SbxObject*)xRef)->SetGraphic( aGraphic );
rPar.Get(0)->PutObject( xRef );
}
- delete pStream;
}
RTLFUNC(SavePicture)
@@ -4601,7 +4601,7 @@ RTLFUNC(MsgBox)
}
nType &= (16+32+64);
- MessBox* pBox = 0;
+ boost::scoped_ptr<MessBox> pBox;
SolarMutexGuard aSolarGuard;
@@ -4609,19 +4609,19 @@ RTLFUNC(MsgBox)
switch( nType )
{
case 16:
- pBox = new ErrorBox( pParent, nWinBits, aMsg );
+ pBox.reset(new ErrorBox( pParent, nWinBits, aMsg ));
break;
case 32:
- pBox = new QueryBox( pParent, nWinBits, aMsg );
+ pBox.reset(new QueryBox( pParent, nWinBits, aMsg ));
break;
case 48:
- pBox = new WarningBox( pParent, nWinBits, aMsg );
+ pBox.reset(new WarningBox( pParent, nWinBits, aMsg ));
break;
case 64:
- pBox = new InfoBox( pParent, nWinBits, aMsg );
+ pBox.reset(new InfoBox( pParent, nWinBits, aMsg ));
break;
default:
- pBox = new MessBox( pParent, nWinBits, aTitle, aMsg );
+ pBox.reset(new MessBox( pParent, nWinBits, aTitle, aMsg ));
}
pBox->SetText( aTitle );
sal_uInt16 nRet = (sal_uInt16)pBox->Execute();
@@ -4643,7 +4643,6 @@ RTLFUNC(MsgBox)
nMappedRet = nButtonMap[ nRet ];
}
rPar.Get(0)->PutInteger( nMappedRet );
- delete pBox;
}
RTLFUNC(SetAttr)