mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-12-22 16:30:20 +00:00
Use if guard for alloc in udp recv
This commit is contained in:
parent
04fc8cb309
commit
5c04bb1006
1 changed files with 14 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue