Kaydet (Commit) d47ce6b6 authored tarafından Caolán McNamara's avatar Caolán McNamara

CID#736509 memleaks on early exit

also CID#736508

Change-Id: If3df76d6ff797224fe4214938e50ab624c0617da
üst 4bcdaabe
...@@ -1282,43 +1282,40 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine, ...@@ -1282,43 +1282,40 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine,
int nMinLen = std::min( nDstLen , nSrcLen ); int nMinLen = std::min( nDstLen , nSrcLen );
int nAvgLen = ( nDstLen + nSrcLen )/2; int nAvgLen = ( nDstLen + nSrcLen )/2;
int *pLcsDst = new int[ nMinLen + 1 ]; std::vector<int> aLcsDst( nMinLen + 1 );
int *pLcsSrc = new int[ nMinLen + 1 ]; std::vector<int> aLcsSrc( nMinLen + 1 );
if( CmpOptions.eCmpMode == SVX_CMP_BY_WORD ) if( CmpOptions.eCmpMode == SVX_CMP_BY_WORD )
{ {
int *pTmpLcsDst = new int[ nMinLen + 1 ]; std::vector<int> aTmpLcsDst( nMinLen + 1 );
int *pTmpLcsSrc = new int[ nMinLen + 1 ]; std::vector<int> aTmpLcsSrc( nMinLen + 1 );
WordArrayComparator aCmp( &rDstNd, &rSrcNd ); WordArrayComparator aCmp( &rDstNd, &rSrcNd );
LgstCommonSubseq aSeq( aCmp ); LgstCommonSubseq aSeq( aCmp );
nLcsLen = aSeq.Find( pTmpLcsDst, pTmpLcsSrc ); nLcsLen = aSeq.Find( &aTmpLcsDst[0], &aTmpLcsSrc[0] );
if( CmpOptions.nIgnoreLen ) if( CmpOptions.nIgnoreLen )
{ {
nLcsLen = aSeq.IgnoreIsolatedPieces( pTmpLcsDst, pTmpLcsSrc, nLcsLen = aSeq.IgnoreIsolatedPieces( &aTmpLcsDst[0], &aTmpLcsSrc[0],
aCmp.GetLen1(), aCmp.GetLen2(), aCmp.GetLen1(), aCmp.GetLen2(),
nLcsLen, CmpOptions.nIgnoreLen ); nLcsLen, CmpOptions.nIgnoreLen );
} }
nLcsLen = aCmp.GetCharSequence( pTmpLcsDst, pTmpLcsSrc, nLcsLen = aCmp.GetCharSequence( &aTmpLcsDst[0], &aTmpLcsSrc[0],
pLcsDst, pLcsSrc, nLcsLen ); &aLcsDst[0], &aLcsSrc[0], nLcsLen );
delete[] pTmpLcsDst;
delete[] pTmpLcsSrc;
} }
else else
{ {
CharArrayComparator aCmp( &rDstNd, &rSrcNd ); CharArrayComparator aCmp( &rDstNd, &rSrcNd );
LgstCommonSubseq aSeq( aCmp ); LgstCommonSubseq aSeq( aCmp );
nLcsLen = aSeq.Find( pLcsDst, pLcsSrc ); nLcsLen = aSeq.Find( &aLcsDst[0], &aLcsSrc[0] );
if( CmpOptions.nIgnoreLen ) if( CmpOptions.nIgnoreLen )
{ {
nLcsLen = aSeq.IgnoreIsolatedPieces( pLcsDst, pLcsSrc, nDstLen, nLcsLen = aSeq.IgnoreIsolatedPieces( &aLcsDst[0], &aLcsSrc[0], nDstLen,
nSrcLen, nLcsLen, nSrcLen, nLcsLen,
CmpOptions.nIgnoreLen ); CmpOptions.nIgnoreLen );
} }
...@@ -1329,8 +1326,8 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine, ...@@ -1329,8 +1326,8 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine,
int nCnt = 1; int nCnt = 1;
for( int i = 0; i < nLcsLen; i++ ) for( int i = 0; i < nLcsLen; i++ )
{ {
if( i != nLcsLen - 1 && pLcsDst[i] + 1 == pLcsDst[i + 1] if( i != nLcsLen - 1 && aLcsDst[i] + 1 == aLcsDst[i + 1]
&& pLcsSrc[i] + 1 == pLcsSrc[i + 1] ) && aLcsSrc[i] + 1 == aLcsSrc[i + 1] )
{ {
nCnt++; nCnt++;
} }
...@@ -1351,10 +1348,10 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine, ...@@ -1351,10 +1348,10 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine,
int nSkip = 0; int nSkip = 0;
for( int i = 0; i <= nLcsLen; i++ ) for( int i = 0; i <= nLcsLen; i++ )
{ {
int nDstFrom = i ? (pLcsDst[i - 1] + 1) : 0; int nDstFrom = i ? (aLcsDst[i - 1] + 1) : 0;
int nDstTo = ( i == nLcsLen ) ? nDstLen : pLcsDst[i]; int nDstTo = ( i == nLcsLen ) ? nDstLen : aLcsDst[i];
int nSrcFrom = i ? (pLcsSrc[i - 1] + 1) : 0; int nSrcFrom = i ? (aLcsSrc[i - 1] + 1) : 0;
int nSrcTo = ( i == nLcsLen ) ? nSrcLen : pLcsSrc[i]; int nSrcTo = ( i == nLcsLen ) ? nSrcLen : aLcsSrc[i];
SwPaM aPam( rDstNd, nDstTo + nSkip ); SwPaM aPam( rDstNd, nDstTo + nSkip );
...@@ -1395,9 +1392,6 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine, ...@@ -1395,9 +1392,6 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine,
} }
} }
delete[] pLcsDst;
delete[] pLcsSrc;
bRet = true; bRet = true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment