Without some code of where things are crashing, we can only speculate. There are a million things that could be going wrong, such as
- Deleting memory twice (especially likely if you copy pointers around)
- Deleting a pointer that was never initialized
- Deleting a pointer that was assigned to garbage
- Deleting a pointer to memory that was allocated with something other than new
- Deleting a pointer that points to an item not on the heap (i.e. an item on the stack or a global variable)
- If you have an array of pointers, deleting a pointer off the end of the array
- Deleting a pointer that was allocated from another instance of the C++ runtime (e.g. calling new from a DLL and delete from the main exe or visa versa)
- Calling delete on memory allocated with new. Calling delete on memory allocated with new (These may not always crash, but it is still wrong and undefined behavior).
I am sure there are more that I didn’t think of off the top of my head.