Crikey. Whenever I allocate memory off the heap and delete it in the destructor, my program crashes. A la:

Code:
num_steps = 2;
ai = new aistep [num_steps];

/* .... */

enemy::~enemy ()
{
	if (ai) {
		if (num_steps > 1)
			delete[] ai;
		else
			delete ai;
		
		ai = NULL;
	}
}
Now if I comment all that code in the destructor out, the program starts and ends fine. No matter how I do it (no num_steps check , no if (ai) check, no ai = NULL, etc) it always crashes. And it does thise for other things too, not just classes but for basic types too. Anything allocated dynamically works, but deleting it and the whole shebang crashes.

What am I doing wrong? Am I not supposed to delete stuff in the destructor? Is dynamically allocated memory deleted automatically in destructors? (I didn't think it was...)

Thanks!