From 07dfd766ed0b1ae69c12bf63de1636e83a5c9603 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 8 Apr 2003 12:05:49 +0000 Subject: [PATCH] PATCH: [ 716744 ] Fix CrystalEditor memory leaks --- Src/editlib/ccrystaltextbuffer.cpp | 12 ++++++------ Src/editlib/ccrystaltextview.cpp | 24 ++++++++++++------------ Src/readme.txt | 4 ++++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Src/editlib/ccrystaltextbuffer.cpp b/Src/editlib/ccrystaltextbuffer.cpp index 4fc52fdbc..f3a6fbcde 100644 --- a/Src/editlib/ccrystaltextbuffer.cpp +++ b/Src/editlib/ccrystaltextbuffer.cpp @@ -115,7 +115,7 @@ void CCrystalTextBuffer::SUndoRecord:: FreeText () { if (HIWORD ((DWORD) m_pszText) != 0) - delete m_pszText; + delete[] m_pszText; } @@ -256,7 +256,7 @@ AppendLine (int nLineIndex, LPCTSTR pszChars, int nLength /*= -1*/ ) TCHAR *pcNewBuf = new TCHAR[li.m_nMax]; if (li.m_nLength > 0) memcpy (pcNewBuf, li.m_pcLine, sizeof (TCHAR) * li.m_nLength); - delete li.m_pcLine; + delete[] li.m_pcLine; li.m_pcLine = pcNewBuf; } memcpy (li.m_pcLine + li.m_nLength, pszChars, sizeof (TCHAR) * nLength); @@ -272,7 +272,7 @@ FreeAll () for (int I = 0; I < nCount; I++) { if (m_aLines[I].m_nMax > 0) - delete m_aLines[I].m_pcLine; + delete[] m_aLines[I].m_pcLine; } m_aLines.RemoveAll (); @@ -919,7 +919,7 @@ InternalDeleteText (CCrystalTextView * pSource, int nStartLine, int nStartChar, int nDelCount = nEndLine - nStartLine; for (int L = nStartLine + 1; L <= nEndLine; L++) - delete m_aLines[L].m_pcLine; + delete[] m_aLines[L].m_pcLine; m_aLines.RemoveAt (nStartLine + 1, nDelCount); // nEndLine is no more valid @@ -927,7 +927,7 @@ InternalDeleteText (CCrystalTextView * pSource, int nStartLine, int nStartChar, if (nRestCount > 0) { AppendLine (nStartLine, pszRestChars, nRestCount); - delete pszRestChars; + delete[] pszRestChars; } if (pSource!=NULL) @@ -1011,7 +1011,7 @@ InternalInsertText (CCrystalTextView * pSource, int nLine, int nPos, LPCTSTR psz } if (pszRestChars != NULL) - delete pszRestChars; + delete[] pszRestChars; context.m_ptEnd.x = nEndChar; context.m_ptEnd.y = nEndLine; diff --git a/Src/editlib/ccrystaltextview.cpp b/Src/editlib/ccrystaltextview.cpp index 6df71bdba..bdb277855 100644 --- a/Src/editlib/ccrystaltextview.cpp +++ b/Src/editlib/ccrystaltextview.cpp @@ -498,7 +498,7 @@ CCrystalTextView::~CCrystalTextView () } if (m_pszMatched) { - delete m_pszMatched; + delete[] m_pszMatched; m_pszMatched = NULL; } //BEGIN SW @@ -1310,8 +1310,8 @@ DrawSingleLine (CDC * pdc, const CRect & rc, int nLineIndex) } */ //END SW - delete anBreaks; - delete pBuf; + delete[] anBreaks; + delete[] pBuf; } COLORREF CCrystalTextView:: @@ -1588,7 +1588,7 @@ ResetView () } if (m_pnActualLineLength != NULL) { - delete m_pnActualLineLength; + delete[] m_pnActualLineLength; m_pnActualLineLength = NULL; } m_nParseArraySize = 0; @@ -1789,7 +1789,7 @@ int CCrystalTextView::CharPosToPoint( int nLineIndex, int nCharPos, CPoint &char charPoint.y = i + 1; int nReturnVal = (i >= 0)? anBreaks[i] : 0; - delete anBreaks; + delete[] anBreaks; return nReturnVal; } @@ -1840,7 +1840,7 @@ int CCrystalTextView::CursorPointToCharPos( int nLineIndex, const CPoint &curPoi break; } } - delete anBreaks; + delete[] anBreaks; return nIndex; } @@ -1880,7 +1880,7 @@ int CCrystalTextView::SubLineEndToCharPos( int nLineIndex, int nSubLineOffset ) ASSERT( nSubLineOffset >= 0 && nSubLineOffset <= nBreaks ); int nReturnVal = anBreaks[nSubLineOffset] - 1; - delete anBreaks; + delete[] anBreaks; return nReturnVal; } @@ -1907,7 +1907,7 @@ int CCrystalTextView::SubLineHomeToCharPos( int nLineIndex, int nSubLineOffset ) ASSERT( nSubLineOffset > 0 && nSubLineOffset <= nBreaks ); int nReturnVal = anBreaks[nSubLineOffset - 1]; - delete anBreaks; + delete[] anBreaks; return nReturnVal; } @@ -2198,7 +2198,7 @@ RecalcPageLayouts (CDC * pdc, CPrintInfo * pInfo) nLimit += 32; int *pnNewPages = new int[nLimit]; memcpy (pnNewPages, m_pnPages, sizeof (int) * m_nPrintPages); - delete m_pnPages; + delete[] m_pnPages; m_pnPages = pnNewPages; } ASSERT (nLimit > m_nPrintPages); @@ -2245,7 +2245,7 @@ OnEndPrinting (CDC * pdc, CPrintInfo * pInfo) } if (m_pnPages != NULL) { - delete m_pnPages; + delete[] m_pnPages; m_pnPages = NULL; } m_nPrintPages = 0; @@ -2947,7 +2947,7 @@ ClientToText (const CPoint & point) nIndex ++; } - delete anBreaks; + delete[] anBreaks; ASSERT(nIndex >= 0 && nIndex <= nLength); pt.x = nIndex; @@ -3193,7 +3193,7 @@ CalculateActualOffset (int nLineIndex, int nCharIndex) for( int J = nBreaks - 1; J >= 0 && nCharIndex < anBreaks[J]; J-- ); nPreBreak = anBreaks[J]; } - delete anBreaks; + delete[] anBreaks; //END SW for (int I = 0; I < nCharIndex; I++) { diff --git a/Src/readme.txt b/Src/readme.txt index 1525d4354..beb7ce706 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,7 @@ +2003-04-08 Kimmo + PATCH: [ 716744 ] Fix CrystalEditor memory leaks + editlib: ccrystaltextbuffer.cpp ccrystaltextview.cpp + 2003-04-07 Kimmo PATCH: [ 716308 ] Disable italic text editlib: ccrystaltextview.cpp -- 2.11.0