diff --git a/packet.c b/packet.c index d51c6404..832cff96 100644 --- a/packet.c +++ b/packet.c @@ -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;