From da984767249677a38b977227523f9d980c637bd1 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 27 Oct 2008 18:47:13 +0300 Subject: [PATCH] Prevent crash at access to deleted social data for player. Remove social data at logout instead ~Player that called also for temporary Player object for Player::MinimalLoadFromDB call. --- src/game/Player.cpp | 6 ++---- src/game/SpellEffects.cpp | 2 +- src/game/WorldSession.cpp | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index ab3e98e..ed23d9c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -426,10 +426,8 @@ Player::~Player () { CleanupsBeforeDelete(); - if(m_uint32Values) // only for fully created Object - { - sSocialMgr.RemovePlayerSocial(GetGUIDLow()); - } + // it must be unloaded already in PlayerLogout and accessed only for loggined player + //m_social = NULL; // Note: buy back item already deleted from DB when player was saved for(int i = 0; i < PLAYER_SLOTS_COUNT; ++i) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 6525efe..e711143 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4945,7 +4945,7 @@ void Spell::EffectDuel(uint32 i) Player *target = (Player*)unitTarget; // caster or target already have requested duel - if( caster->duel || target->duel || target->GetSocial()->HasIgnore(caster->GetGUIDLow()) ) + if( caster->duel || target->duel || !target->GetSocial() || target->GetSocial()->HasIgnore(caster->GetGUIDLow()) ) return; // Players can only fight a duel with each other outside (=not inside dungeons and not in capital cities) diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 60c0605..261d613 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -380,6 +380,7 @@ void WorldSession::LogoutPlayer(bool Save) ///- Delete the player object _player->CleanupsBeforeDelete(); // do some cleanup before deleting to prevent crash at crossreferences to already deleted data + sSocialMgr.RemovePlayerSocial (_player->GetGUIDLow ()); delete _player; _player = NULL; -- 2.11.4.GIT