From dcfcaab9b04f7c716f1257b17a692b808142a6ac Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sat, 17 Aug 2024 21:27:53 +0800 Subject: [PATCH] [raknet] Match `AllocPacket(...)` --- raknet/RakPeer.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/raknet/RakPeer.cpp b/raknet/RakPeer.cpp index fa45630..3d255b4 100644 --- a/raknet/RakPeer.cpp +++ b/raknet/RakPeer.cpp @@ -143,9 +143,18 @@ Packet *AllocPacket(unsigned dataSize) Packet *AllocPacket(unsigned dataSize, unsigned char *data) { Packet *p = (Packet *)malloc(sizeof(Packet)); - p->data=data; - p->length=dataSize; - p->deleteData=true; + p->data=NULL; + p->length=0; + p->deleteData=false; + if(dataSize != 0) + { + if(data != NULL) + { + p->data=data; + p->length=dataSize; + p->deleteData=true; + } + } return p; }