It seems that you try either to delete memory which has already been released or to delete memory which wasn't allocated dynamically on heap, but on stack. Eg.
Code:
void func()
{
int i = 0;
int* pi = &i;
delete pi; // we're deleting non-heap memory
}
when you will look in debugger the falue of x will be probably 0xCCCCCCCC or 0xC0C0C0C0 or something like that. If x is 0 then it is a null pointer exception.
Also an error is:
int *x = new int[elements];
for(int i = 0; i <= elements; i++)
{
x = something...
//error when i will be elements;, put elements - 1
//instead of elements or < instead of <=
}
this error is often raised when working especially with arrays and strings. For example
int len = strlen(somestring);
char* acopy = new char[len];//to avoid error put there len+1
strcpy(acopy, somestrimg);//there is an error
Many of these errors you will not get when working in release mode or when just lauching the exe module. But these errors are dangerous.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.