Skip to content

Commit

Permalink
(svn r21182) -Fix: possible just-freed memory reads
Browse files Browse the repository at this point in the history
  • Loading branch information
rubidium42 committed Nov 14, 2010
1 parent a9da53c commit 673b371
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/network/core/tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 2 additions & 5 deletions src/network/network_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 673b371

Please sign in to comment.