Add missing sanity checks to BuddyManager

This commit is contained in:
Gent S 2020-11-26 22:28:18 -05:00
parent 71d1212877
commit 15dd0a2fc3

View File

@ -94,6 +94,9 @@ void BuddyManager::requestBuddy(CNSocket* sock, CNPacketData* data) {
Player* plr = PlayerManager::getPlayer(sock);
Player* otherPlr = PlayerManager::getPlayerFromID(req->iBuddyID);
if (otherPlr == nullptr)
return;
if (getAvailableBuddySlot(plr) == -1 || getAvailableBuddySlot(otherPlr) == -1)
{
INITSTRUCT(sP_FE2CL_REP_REQUEST_MAKE_BUDDY_FAIL, failResp);
@ -166,6 +169,9 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
Player* plr = PlayerManager::getPlayer(sock);
Player* otherPlr = PlayerManager::getPlayerFromID(req->iBuddyID);
if (otherPlr == nullptr)
return; // sanity check
CNSocket* otherSock = PlayerManager::getSockFromID(otherPlr->iID);
int slotA = getAvailableBuddySlot(plr);