summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-03-25 20:07:48 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-03-25 20:08:26 +0900
commitdd52330db6551c3e96fce5ba17ff823882d158fd (patch)
tree101c7be6d8919782cae3943af9f1568e0d10b898 /basic
parent259ec024baf0592fe2d7dfea32ee052f8b5b3d20 (diff)
Avoid possible resource leaks by boost::scoped_array
Change-Id: I14e1f7ef217eb5e8e9db9f8962af868ab0a4ab81
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/methods.cxx12
-rw-r--r--basic/source/runtime/methods1.cxx7
-rw-r--r--basic/source/runtime/runtime.cxx12
-rw-r--r--basic/source/sbx/sbxdec.cxx7
4 files changed, 17 insertions, 21 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 0cc3db1a02fc..b35d8d626ddd 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -55,6 +55,7 @@
#include <com/sun/star/script/XErrorQuery.hpp>
#include <ooo/vba/XHelperInterface.hpp>
#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
+#include <boost/scoped_array.hpp>
using namespace comphelper;
using namespace osl;
@@ -445,28 +446,25 @@ RTLFUNC(CurDir)
const int PATH_INCR = 250;
int nSize = PATH_INCR;
- char* pMem;
+ boost::scoped_array<char> pMem;
while( true )
{
- pMem = new char[nSize];
+ pMem.reset(new char[nSize]);
if( !pMem )
{
StarBASIC::Error( SbERR_NO_MEMORY );
return;
}
- if( getcwd( pMem, nSize-1 ) != NULL )
+ if( getcwd( pMem.get(), nSize-1 ) != NULL )
{
- rPar.Get(0)->PutString( OUString::createFromAscii(pMem) );
- delete [] pMem;
+ rPar.Get(0)->PutString( OUString::createFromAscii(pMem.get()) );
return;
}
if( errno != ERANGE )
{
StarBASIC::Error( SbERR_INTERNAL_ERROR );
- delete [] pMem;
return;
}
- delete [] pMem;
nSize += PATH_INCR;
};
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 6b52e281600e..00c8b7d1a1eb 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -55,6 +55,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/i18n/LocaleCalendar.hpp>
#include <com/sun/star/sheet/XFunctionAccess.hpp>
+#include <boost/scoped_array.hpp>
using namespace comphelper;
using namespace com::sun::star::i18n;
@@ -1277,9 +1278,9 @@ void PutGet( SbxArray& rPar, sal_Bool bPut )
{
sal_Size nFPos = pStrm->Tell();
short nDims = pArr->GetDims();
- short* pDims = new short[ nDims ];
- bRet = lcl_WriteReadSbxArray(*pArr,pStrm,!bRandom,nDims,pDims,bPut);
- delete [] pDims;
+ boost::scoped_array<short> pDims(new short[ nDims ]);
+ bRet = lcl_WriteReadSbxArray(*pArr,pStrm,!bRandom,nDims,pDims.get(),bPut);
+ pDims.reset();
if( nBlockLen )
pStrm->Seek( nFPos + nBlockLen );
}
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 3ee4b93c2ed7..66026e0deefc 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -66,6 +66,7 @@
#include "sbintern.hxx"
#include "sbunoobj.hxx"
#include <basic/codecompletecache.hxx>
+#include <boost/scoped_array.hpp>
using com::sun::star::uno::Reference;
@@ -4453,9 +4454,9 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
bool bRangeError = false;
// Store dims to use them for copying later
- sal_Int32* pLowerBounds = new sal_Int32[nDims];
- sal_Int32* pUpperBounds = new sal_Int32[nDims];
- sal_Int32* pActualIndices = new sal_Int32[nDims];
+ boost::scoped_array<sal_Int32> pLowerBounds(new sal_Int32[nDims]);
+ boost::scoped_array<sal_Int32> pUpperBounds(new sal_Int32[nDims]);
+ boost::scoped_array<sal_Int32> pActualIndices(new sal_Int32[nDims]);
if( nDimsOld != nDimsNew )
{
bRangeError = true;
@@ -4488,11 +4489,8 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
// (It would be faster to work on the flat internal data array of an
// SbyArray but this solution is clearer and easier)
implCopyDimArray_DCREATE( pArray, pOldArray, nDims - 1,
- 0, pActualIndices, pLowerBounds, pUpperBounds );
+ 0, pActualIndices.get(), pLowerBounds.get(), pUpperBounds.get() );
}
- delete [] pUpperBounds;
- delete [] pLowerBounds;
- delete [] pActualIndices;
refRedimpArray = NULL;
}
}
diff --git a/basic/source/sbx/sbxdec.cxx b/basic/source/sbx/sbxdec.cxx
index 276b78857e56..c9fd347e4c9a 100644
--- a/basic/source/sbx/sbxdec.cxx
+++ b/basic/source/sbx/sbxdec.cxx
@@ -23,7 +23,7 @@
#include "sbxconv.hxx"
#include <com/sun/star/bridge/oleautomation/Decimal.hpp>
-
+#include <boost/scoped_array.hpp>
// Implementation SbxDecimal
SbxDecimal::SbxDecimal( void )
@@ -206,7 +206,7 @@ bool SbxDecimal::setString( OUString* pOUString )
if( cDecimalSep != '.' || cThousandSep != ',' )
{
int nLen = pOUString->getLength();
- sal_Unicode* pBuffer = new sal_Unicode[nLen + 1];
+ boost::scoped_array<sal_Unicode> pBuffer(new sal_Unicode[nLen + 1]);
pBuffer[nLen] = 0;
const sal_Unicode* pSrc = pOUString->getStr();
@@ -224,8 +224,7 @@ bool SbxDecimal::setString( OUString* pOUString )
pBuffer[i] = ',';
i++;
}
- hResult = VarDecFromStr( (OLECHAR*)pBuffer, nLANGID, 0, &maDec );
- delete [] pBuffer;
+ hResult = VarDecFromStr( (OLECHAR*)pBuffer.get(), nLANGID, 0, &maDec );
}
else
{