- more NULL checking for safer execution

This commit is contained in:
Mark Vejvoda 2010-08-20 22:17:30 +00:00
parent 09f7eecf06
commit 0e82836e01
2 changed files with 3 additions and 3 deletions

View File

@ -252,7 +252,7 @@ void ConnectionSlot::update(bool checkForNewClients) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] client will be assigned to the next open slot\n",__FILE__,__FUNCTION__);
if(socket != NULL) {
NetworkMessageIntro networkMessageIntro(getNetworkVersionString(), socket->getHostName(), playerIndex, nmgstOk);
NetworkMessageIntro networkMessageIntro(getNetworkVersionString(), getHostName(), playerIndex, nmgstOk);
sendMessage(&networkMessageIntro);
}
}

View File

@ -1229,9 +1229,9 @@ bool Socket::isConnected() {
string Socket::getHostName() {
const int strSize= 256;
char hostname[strSize];
char hostname[strSize]="";
gethostname(hostname, strSize);
return hostname;
return (hostname[0] != '\0' ? hostname : "");
}
string Socket::getIp() {