OSDN Git Service

PATCH: [ 716744 ] Fix CrystalEditor memory leaks
authorKimmo Varis <kimmov@gmail.com>
Tue, 8 Apr 2003 12:05:49 +0000 (12:05 +0000)
committerKimmo Varis <kimmov@gmail.com>
Tue, 8 Apr 2003 12:05:49 +0000 (12:05 +0000)
Src/editlib/ccrystaltextbuffer.cpp
Src/editlib/ccrystaltextview.cpp
Src/readme.txt

index 4fc52fd..f3a6fbc 100644 (file)
@@ -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;
index 6df71bd..bdb2778 100644 (file)
@@ -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++)
     {
index 1525d43..beb7ce7 100644 (file)
@@ -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