If you're using something like GetTypeInstances, it'll return NULL and 0 if no instances exist, so you just need some basic error checking. If you're holding a pointer to an object (CRunObject*), if it's destroyed the pointer becomes invalid. You must check the object->info.destroying flag in OnFrame2(), and if it's set true, you must stop using the pointer (set it to NULL/erase it/whatever's appropriate).