mirror of
https://github.com/lsalzman/enet
synced 2024-11-21 06:25:59 -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
9
packet.c
9
packet.c
|
@ -89,8 +89,13 @@ enet_packet_resize (ENetPacket * packet, size_t dataLength)
|
||||||
if (newData == NULL)
|
if (newData == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy (newData, packet -> data, packet -> dataLength);
|
if (packet -> data != NULL)
|
||||||
enet_free (packet -> data);
|
{
|
||||||
|
if (packet -> dataLength > 0)
|
||||||
|
memcpy (newData, packet -> data, packet -> dataLength);
|
||||||
|
|
||||||
|
enet_free (packet -> data);
|
||||||
|
}
|
||||||
|
|
||||||
packet -> data = newData;
|
packet -> data = newData;
|
||||||
packet -> dataLength = dataLength;
|
packet -> dataLength = dataLength;
|
||||||
|
|
Loading…
Reference in a new issue