Tag Archives: 0xC0000374: A heap has been corrupted !

[Solved] 0xC0000374: A heap has been corrupted !

This problem is caused by memory overrun

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;

//Here the assignment exceeds the size of the array, will be in the indeterminate time error!
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;