Use if guard for alloc in udp recv

This commit is contained in:
Jack Garrard 2022-10-27 04:46:36 -07:00
parent 04fc8cb309
commit 5c04bb1006

View file

@ -250,18 +250,21 @@ bool SocketClient::recv() {
this->mHasRecvUdp = true;
char* packetBuf = (char*)mHeap->alloc(fullSize);
if (packetBuf){
memcpy(packetBuf, recvBuf, fullSize);
Packet *packet = reinterpret_cast<Packet*>(packetBuf);
if(!mRecvQueue.isFull()) {
mRecvQueue.push((s64)packet, sead::MessageQueue::BlockType::NonBlocking);
} else {
mHeap->free(packetBuf);
}
if (!packetBuf) {
return true
}
memcpy(packetBuf, recvBuf, fullSize);
Packet *packet = reinterpret_cast<Packet*>(packetBuf);
if(!mRecvQueue.isFull()) {
mRecvQueue.push((s64)packet, sead::MessageQueue::BlockType::NonBlocking);
} else {
mHeap->free(packetBuf);
}
return true;
}