OSDN Git Service

CrystalEdit Sample: Fix crash when loading a file that includes a line over 256 chars
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 6 Nov 2016 13:02:31 +0000 (22:02 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 6 Nov 2016 13:02:31 +0000 (22:02 +0900)
Externals/crystaledit/editlib/ccrystaltextbuffer.cpp

index d435c8a..5c8d223 100644 (file)
@@ -448,9 +448,9 @@ LoadFromFile (LPCTSTR pszFileName, CRLFSTYLE nCrlfStyle /*= CRLF_STYLE_AUTOMATIC
               //  Reallocate line buffer
               nCurrentMax += 256;
                          TCHAR *pcNewLineBuf = new TCHAR[nCurrentMax];
-                         memcpy(pcNewLineBuf, pcLineBuf, nCurrentMax - 256);
+                         memcpy(pcNewLineBuf, pcLineBuf, sizeof(TCHAR) * (nCurrentMax - 256));
                          delete [] pcLineBuf;
-                         pcNewLineBuf = pcLineBuf;
+                         pcLineBuf = pcNewLineBuf;
             }
 
           // detect both types of EOL for each line