From 0e82836e013cd3ec70f18e78480611ccb71b82d9 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 20 Aug 2010 22:17:30 +0000 Subject: [PATCH] - more NULL checking for safer execution --- source/glest_game/network/connection_slot.cpp | 2 +- source/shared_lib/sources/platform/posix/socket.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index a3ab34c00..b7b214597 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -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); } } diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 09b2d5632..2dec1e63a 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -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() {