Skip to content

Commit

Permalink
bound totalWaitingData decrement
Browse files Browse the repository at this point in the history
  • Loading branch information
lsalzman committed Jul 24, 2024
1 parent a52811e commit 1e80a78
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
#include <string.h>
#define ENET_BUILDING_LIB 1
#include "enet/utility.h"
#include "enet/enet.h"

/** @defgroup peer ENet peer functions
Expand Down Expand Up @@ -249,7 +250,7 @@ enet_peer_receive (ENetPeer * peer, enet_uint8 * channelID)

enet_free (incomingCommand);

peer -> totalWaitingData -= packet -> dataLength;
peer -> totalWaitingData -= ENET_MIN (peer -> totalWaitingData, packet -> dataLength);

return packet;
}
Expand Down Expand Up @@ -295,7 +296,7 @@ enet_peer_remove_incoming_commands (ENetPeer * peer, ENetList * queue, ENetListI
{
-- incomingCommand -> packet -> referenceCount;

peer -> totalWaitingData -= incomingCommand -> packet -> dataLength;
peer -> totalWaitingData -= ENET_MIN (peer -> totalWaitingData, incomingCommand -> packet -> dataLength);

if (incomingCommand -> packet -> referenceCount == 0)
enet_packet_destroy (incomingCommand -> packet);
Expand Down

0 comments on commit 1e80a78

Please sign in to comment.