I am using Visual Studio 2005. While debugging code I am getting following error message and after that it is adding break,
Debug Error !
Program :-
Heap Corruption detected : after normal block c#2368 at 0x01d21e30. CRT detected that the application wrote memory after end of heap buffer.
Above error comes on the line
delete values[i];
where values is a vector of (const wchar_t *).
Anybody having idea where this error coming from?
This is for sure the result of a buffer write overflow. That means at some place you are writing more chars to a buffer than is allocated for it.
You could use
std::wstringinstead of plain buffers which would eliminate the need for you to manage the buffers for you. Verify each write operation to the buffers.The overflow is detected on deletion as the heap manager then checks for some pattern at the beginning and the end of the buffers in debug mode.
As others suggested also take care of matching allocation and deallocation: