错误源头一,数组访问越界:
大家先看如下一段程序:
int* a = new int[5];
a[5] = 3; // 这儿访问越界了
delete[] a;
在delete[] a;这句代码处将会出现:DAMAGE:After normal block(#93)的错误。
错误源头二:
char* pBuffer = new char[2];
int v = 12345;
memcpy(pBuffer, &v, sizeof(v));
delete[] pBuffer;
正如代码所表示的,我的缓冲区pBuffer有且仅分配了2Bytes的空间,然面我却向它塞了4Bytes的值,显然这是不正确的,DEBUG一下,将出现:DAMAGE:After normal block(#94)的错误。
int* a = new int[5];
a[5] = 3; // 这儿访问越界了
delete[] a;
在delete[] a;这句代码处将会出现:DAMAGE:After normal block(#93)的错误。
错误源头二:
char* pBuffer = new char[2];
int v = 12345;
memcpy(pBuffer, &v, sizeof(v));
delete[] pBuffer;
正如代码所表示的,我的缓冲区pBuffer有且仅分配了2Bytes的空间,然面我却向它塞了4Bytes的值,显然这是不正确的,DEBUG一下,将出现:DAMAGE:After normal block(#94)的错误。
下面是我自己遇到的错误:
char* dir_temp;
CString dirTemp;
CString dirTemp;
dir_temp = dirTemp.GetBuffer(dirTemp.GetLength());
strcat(dir_temp, E_Quotes);//会造成数组越界,需要 dirTemp.GetLength()+100;
strcat(dir_temp, E_Quotes);//会造成数组越界,需要 dirTemp.GetLength()+100;