summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-01-02 22:17:14 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-01-02 22:30:31 +0100
commit99c83e7702cc19fe1b1b5ff72499a2f97e98ef7e (patch)
tree69130fcb1306d6fb980fa64beeaa4be90868f0db /src
parenta9af783d51082103fac24b83440b9bd302a94bf4 (diff)
downloadmana-client-99c83e7702cc19fe1b1b5ff72499a2f97e98ef7e.tar.gz
mana-client-99c83e7702cc19fe1b1b5ff72499a2f97e98ef7e.tar.bz2
mana-client-99c83e7702cc19fe1b1b5ff72499a2f97e98ef7e.tar.xz
mana-client-99c83e7702cc19fe1b1b5ff72499a2f97e98ef7e.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/net/tmwa/adminhandler.cpp9
1 files 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<Player *>(being))
+ {
+ player->setIp(ip);
+ player->updateName();
+ }
break;
}
}