From 99c83e7702cc19fe1b1b5ff72499a2f97e98ef7e Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 2 Jan 2011 22:17:14 +0100 Subject: Fixed possible crash when receiving player IP Could happen sometimes for GMs when the message is received either before the player instance is created or after it was destroyed. Also changed to a dynamic_cast, putting a little less trust in the server. Reviewed-by: Freeyorp --- src/net/tmwa/adminhandler.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index c75ec217..e2c3c74b 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -69,9 +69,12 @@ void AdminHandler::handleMessage(Net::MessageIn &msg) case SMSG_ADMIN_IP: id = msg.readInt32(); int ip = msg.readInt32(); - Player *player = (Player *)beingManager->findBeing(id); - player->setIp(ip); - player->updateName(); + Being *being = beingManager->findBeing(id); + if (Player *player = dynamic_cast(being)) + { + player->setIp(ip); + player->updateName(); + } break; } } -- cgit v1.2.3-70-g09d2