I will make sure to check that further pointers are valid. I've edited this code and tested it without a pet, with an enchanter animation, and with a charmed pet. All work properly with no crashes now.
My thanks to Cavedude for catching the bug (as well as running TGC and PEQ... my son and I enjoy your server).
Code:
void Mob::SetInvisible(bool state)
{
invisible = state;
SendAppearancePacket(AT_Invis, invisible);
// Invis breaks charms
if ((this->GetPetType() == petCharmed) && invisible)
{
Mob* formerpet = this->GetPet();
if(formerpet)
formerpet->BuffFadeByEffect(SE_Charm);
}
}