add some safety checks to enet_packet_resize
Some checks failed
CMake / CMake ${{ matrix.os }} ${{ matrix.build_type }} (Debug, macos-latest) (push) Has been cancelled
CMake / CMake ${{ matrix.os }} ${{ matrix.build_type }} (Debug, ubuntu-latest) (push) Has been cancelled
CMake / CMake ${{ matrix.os }} ${{ matrix.build_type }} (Debug, windows-latest) (push) Has been cancelled
CMake / CMake ${{ matrix.os }} ${{ matrix.build_type }} (Release, macos-latest) (push) Has been cancelled
CMake / CMake ${{ matrix.os }} ${{ matrix.build_type }} (Release, ubuntu-latest) (push) Has been cancelled
CMake / CMake ${{ matrix.os }} ${{ matrix.build_type }} (Release, windows-latest) (push) Has been cancelled

This commit is contained in:
Lee Salzman 2024-06-28 22:28:14 -04:00
parent 7083138fd4
commit 0b924c79ce

View file

@ -89,8 +89,13 @@ enet_packet_resize (ENetPacket * packet, size_t dataLength)
if (newData == NULL)
return -1;
if (packet -> data != NULL)
{
if (packet -> dataLength > 0)
memcpy (newData, packet -> data, packet -> dataLength);
enet_free (packet -> data);
}
packet -> data = newData;
packet -> dataLength = dataLength;