Skip to content

Commit

Permalink
add some safety checks to enet_packet_resize
Browse files Browse the repository at this point in the history
  • Loading branch information
lsalzman committed Jun 29, 2024
1 parent 7083138 commit 0b924c7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ enet_packet_resize (ENetPacket * packet, size_t dataLength)
if (newData == NULL)
return -1;

memcpy (newData, packet -> data, packet -> dataLength);
enet_free (packet -> data);

if (packet -> data != NULL)
{
if (packet -> dataLength > 0)
memcpy (newData, packet -> data, packet -> dataLength);

enet_free (packet -> data);
}

packet -> data = newData;
packet -> dataLength = dataLength;

Expand Down

0 comments on commit 0b924c7

Please sign in to comment.