When,i try to assign null value to my pointer,it sometimes crashes on that line. The code is
something like this :
if(s_counter != NULL)
{
delete s_counter;
s_counter = NULL; // it sometimes crashes here.
}
This is not reproducable,100%,but it occurs frequently. Can anybody help in this?
Note that although it is OK to delete a NULL pointer, it is not necessarily OK to delete a a non-NULL pointer. The pointer must have been allocated with new and must not already have been deleted. Note also that allocating NULL to deleted pointers can add to a false sense of security – simply checking for NULL is not enough, your programs memory allocation semantics need to be correct too.