void PckFileChunk::DeleteData()
{
if(Data)
{
delete[] Data;
Data=NULL;
}
}
Assertion failed! at delete[]
Hello!
I've got another problem. Sometimes, when I do this:
I get this:
And I already checked if Data (Which is of the type Byte*) is invalid, and it is.(Or maybe not?)
What causes this "assertion failed"?
(1) CrtIsValidHeapPointer checks if a pointer is referring to space in the local heap.
(2) It is redundant and unnecessary to check "if(Data)" before invoking delete[]. delete[] on a null pointer is a safe no-op.
(2) It is redundant and unnecessary to check "if(Data)" before invoking delete[]. delete[] on a null pointer is a safe no-op.
Debug your code.
The pointer you are trying to delete isn't in the local heap. That means it has a bad value. This could be because of any number of reasons; you assigned it a value that you'd already deleted, you overwrite memory elsewhere, stomping on the object that contains the Data member such that it refers to an invalid address, et cetera.
The pointer you are trying to delete isn't in the local heap. That means it has a bad value. This could be because of any number of reasons; you assigned it a value that you'd already deleted, you overwrite memory elsewhere, stomping on the object that contains the Data member such that it refers to an invalid address, et cetera.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement