[Libreoffice-commits] core.git: sc/source
Takeshi Abe
tabe at fixedpoint.jp
Sun Apr 27 06:50:28 PDT 2014
sc/source/core/data/table1.cxx | 5 ++---
sc/source/core/tool/chgtrack.cxx | 12 +++++-------
sc/source/core/tool/interpr4.cxx | 8 ++++----
sc/source/filter/dif/difimp.cxx | 8 +++-----
4 files changed, 14 insertions(+), 19 deletions(-)
New commits:
commit f2e546efd96b5a8b7c0b339cf2673a9b1996190b
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Sun Apr 27 22:45:29 2014 +0900
Avoid possible memory leaks in case of exceptions
Change-Id: Ifd4c87bf038b421a0468edb599eca030c78bad89
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 77de5a8..4827541 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -53,6 +53,7 @@
#include "formula/vectortoken.hxx"
#include <vector>
+#include <boost/scoped_array.hpp>
using ::std::vector;
@@ -1299,7 +1300,7 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY,
if ( !ValidNextPos(nCol, nRow, rMark, bMarked, bUnprotected) )
{
- SCsROW* pNextRows = new SCsROW[MAXCOL+1];
+ boost::scoped_array<SCsROW> pNextRows(new SCsROW[MAXCOL+1]);
SCCOL i;
if ( nMovX > 0 ) // vorwaerts
@@ -1368,8 +1369,6 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY,
}
while ( !ValidNextPos(nCol, nRow, rMark, bMarked, bUnprotected) );
}
-
- delete[] pNextRows;
}
}
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index df37e22..3b5a0b4 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -43,6 +43,7 @@
#include <sfx2/app.hxx>
#include <unotools/useroptions.hxx>
#include <sfx2/sfxsids.hrc>
+#include <boost/scoped_ptr.hpp>
IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionCellListEntry )
IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionLinkEntry )
@@ -1822,9 +1823,8 @@ void ScChangeActionContent::GetFormulaString(
else
{
OSL_FAIL( "ScChangeActionContent::GetFormulaString: aPos != pCell->aPos" );
- ScFormulaCell* pNew = new ScFormulaCell( *pCell, *pCell->GetDocument(), aPos );
+ boost::scoped_ptr<ScFormulaCell> pNew(new ScFormulaCell( *pCell, *pCell->GetDocument(), aPos ));
pNew->GetFormula( rStr );
- delete pNew;
}
}
@@ -4188,15 +4188,13 @@ bool ScChangeTrack::Reject( ScChangeAction* pAct, bool bShared )
if ( !pAct->IsRejectable() )
return false;
- ScChangeActionMap* pMap = NULL;
+ boost::scoped_ptr<ScChangeActionMap> pMap;
if ( pAct->HasDependent() )
{
- pMap = new ScChangeActionMap;
+ pMap.reset(new ScChangeActionMap);
GetDependents( pAct, *pMap, false, true );
}
- bool bRejected = Reject( pAct, pMap, false );
- if ( pMap )
- delete pMap;
+ bool bRejected = Reject( pAct, pMap.get(), false );
return bRejected;
}
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 1a3294d..83197fd 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -72,6 +72,7 @@
#include <basic/basmgr.hxx>
#include <vbahelper/vbaaccesshelper.hxx>
#include <memory>
+#include <boost/scoped_array.hpp>
using namespace com::sun::star;
using namespace formula;
@@ -2635,12 +2636,11 @@ void ScInterpreter::ScExternal()
break;
case PTR_STRING :
{
- sal_Char* pcErg = new sal_Char[ADDIN_MAXSTRLEN];
- ppParam[0] = pcErg;
+ boost::scoped_array<sal_Char> pcErg(new sal_Char[ADDIN_MAXSTRLEN]);
+ ppParam[0] = pcErg.get();
pFuncData->Call(ppParam);
- OUString aUni( pcErg, strlen(pcErg), osl_getThreadTextEncoding() );
+ OUString aUni( pcErg.get(), strlen(pcErg.get()), osl_getThreadTextEncoding() );
PushString( aUni );
- delete[] pcErg;
}
break;
default:
diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx
index 87c3fb0..1ec7e80 100644
--- a/sc/source/filter/dif/difimp.cxx
+++ b/sc/source/filter/dif/difimp.cxx
@@ -32,6 +32,7 @@
#include "scerrors.hxx"
#include "scitems.hxx"
#include "stringutil.hxx"
+#include <boost/scoped_ptr.hpp>
const sal_Unicode pKeyTABLE[] = { 'T', 'A', 'B', 'L', 'E', 0 };
const sal_Unicode pKeyVECTORS[] = { 'V', 'E', 'C', 'T', 'O', 'R', 'S', 0 };
@@ -951,7 +952,7 @@ void DifAttrCache::Apply( ScDocument& rDoc, SCTAB nTab )
{
if( bPlain )
{
- ScPatternAttr* pPatt = NULL;
+ boost::scoped_ptr<ScPatternAttr> pPatt;
for( SCCOL nCol = 0 ; nCol <= MAXCOL ; nCol++ )
{
@@ -959,7 +960,7 @@ void DifAttrCache::Apply( ScDocument& rDoc, SCTAB nTab )
{
if( !pPatt )
{
- pPatt = new ScPatternAttr( rDoc.GetPool() );
+ pPatt.reset(new ScPatternAttr( rDoc.GetPool() ));
pPatt->GetItemSet().Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
rDoc.GetFormatTable()->GetStandardFormat( NUMBERFORMAT_LOGICAL ) ) );
}
@@ -967,9 +968,6 @@ void DifAttrCache::Apply( ScDocument& rDoc, SCTAB nTab )
ppCols[ nCol ]->Apply( rDoc, nCol, nTab, *pPatt );
}
}
-
- if( pPatt )
- delete pPatt;
}
else
{
More information about the Libreoffice-commits
mailing list