0xC0000374: A heap has been corrupted !

原创
2019/06/21 16:17
阅读数 270

这个问题是由于内存越界导致:

const char* fmt = "rdma-ping-%08d: ";
char* base_buffer = new char[buffer_size];
memset(base_buffer, '\0', buffer_size);

/* Put some ascii text in the buffer. */
int start = 65;

//这里赋值超出数组大小,会在不定时报错!!!
int buff_size = buffer_size + 1;
int offset = (int)strlen(fmt);
int c = (unsigned char)start;
for (int i = offset; i < buff_size; i++)
{
	base_buffer[i] = (CHAR)c;
	if (++c > 122)
		c = 65;
}
if (++start > 122)
    start = 65;

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部