diff options
author | rubidium <rubidium@openttd.org> | 2010-11-14 12:05:24 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-11-14 12:05:24 +0000 |
commit | 673b3711b44f019fb5869546b4a3dc2b78882c2a (patch) | |
tree | 1404f7ae1cbaa3d7147cdc670f641e2038eeb4d6 /src | |
parent | a9da53c1068f9279ae82a557d46ece01f5beecd1 (diff) | |
download | openttd-673b3711b44f019fb5869546b4a3dc2b78882c2a.tar.xz |
(svn r21182) -Fix: possible just-freed memory reads
Diffstat (limited to 'src')
-rw-r--r-- | src/network/core/tcp.cpp | 2 | ||||
-rw-r--r-- | src/network/network_server.cpp | 7 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp index 77afac131..3f59efba9 100644 --- a/src/network/core/tcp.cpp +++ b/src/network/core/tcp.cpp @@ -82,6 +82,8 @@ void NetworkTCPSocketHandler::Send_Packet(Packet *packet) * data right now (full network-buffer, it happens ;)) * 3) sending took too long * @param closing_down Whether we are closing down the connection. + * @return \c true if a (part of a) packet could be sent and + * the connection is not closed yet. */ bool NetworkTCPSocketHandler::Send_Packets(bool closing_down) { diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index f3e76ed46..513758811 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -138,9 +138,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta NetworkClientSocket *cs; FOR_ALL_CLIENT_SOCKETS(cs) { if (cs->writable) { - cs->Send_Packets(); - - if (cs->status == STATUS_MAP) { + if (cs->Send_Packets() && cs->status == STATUS_MAP) { /* This client is in the middle of a map-send, call the function for that */ cs->SendMap(); } @@ -451,8 +449,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap() } /* Send all packets (forced) and check if we have send it all */ - this->Send_Packets(); - if (this->IsPacketQueueEmpty()) { + if (this->Send_Packets() && this->IsPacketQueueEmpty()) { /* All are sent, increase the sent_packets */ sent_packets *= 2; } else { |