Jump to content
  • Advertisement
Sign in to follow this  
WuTz

Assertion failed! at delete[]

This topic is 3163 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I've got another problem. Sometimes, when I do this:
void PckFileChunk::DeleteData()
{
    if(Data)
    {
       delete[] Data;
       Data=NULL;
    }
}


I get this: Image and video hosting by TinyPic 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"?

Share this post


Link to post
Share on other sites
Advertisement
(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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I've fixed the problem now. Over some wired ways, I found out that I passed the data from a ID3D10Blob interface directly. And this interface deletes the memory when it gets released.

Everything is fine now :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!