From f47c8521864b64a8fd84f05260970d613898e47e Mon Sep 17 00:00:00 2001 From: faketruth Date: Mon, 2 Jan 2012 19:03:19 +0000 Subject: Fixed crashing bug in cClientHandle::~cClientHandle When there are players in the server, and a client connects as far as the handshake and then disconnects, the server crashed. This is because there is no m_Player yet after the handshake, and the destructor uses m_Player without checking if it exists git-svn-id: http://mc-server.googlecode.com/svn/trunk@163 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/cClientHandle.cpp') diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 10364243e..891140630 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -183,12 +183,14 @@ cClientHandle::~cClientHandle() if( m_LoadedChunks[i] ) m_LoadedChunks[i]->RemoveClient( this ); } + cWorld::PlayerList PlayerList = cRoot::Get()->GetWorld()->GetAllPlayers(); for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr ) { if ((*itr) && (*itr)->GetClientHandle() && strlen(GetUsername()) > 0) { - cPacket_PlayerListItem PlayerList(m_Player->GetColor() + GetUsername(), false, (short)9999); + std::string NameColor = ( m_Player ? m_Player->GetColor() : "" ); + cPacket_PlayerListItem PlayerList(NameColor + GetUsername(), false, (short)9999); (*itr)->GetClientHandle()->Send( PlayerList ); } -- cgit v1.2.3