mirror of
https://github.com/lsalzman/enet
synced 2024-11-20 22:15:57 -07:00
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
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:
parent
7083138fd4
commit
0b924c79ce
1 changed files with 8 additions and 3 deletions
11
packet.c
11
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue