From fffbd86a1014ad169ed2d68ea58cdddf346faa14 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Jul 2015 00:47:44 +0300 Subject: Add missing checks and non null attributes. --- src/net/eathena/beinghandler.cpp | 7 ++++--- src/net/eathena/buyingstorehandler.cpp | 2 ++ src/net/eathena/inventoryhandler.cpp | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/net/eathena') diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 79fddcf18..d12941fcd 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -663,7 +663,6 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg) return; dstBeing = createBeing2(msg, id, job, type); - if (!dstBeing) return; } @@ -831,7 +830,6 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg) return; dstBeing = createBeing2(msg, id, job, type); - if (!dstBeing) return; } @@ -1001,7 +999,6 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg) return; dstBeing = createBeing2(msg, id, job, type); - if (!dstBeing) return; } @@ -1120,6 +1117,8 @@ void BeingHandler::processMapTypeProperty(Net::MessageIn &msg) MapTypeProperty2 props; props.data = static_cast(flags); Game *const game = Game::instance(); + if (!game) + return; Map *const map = game->getCurrentMap(); if (!map) return; @@ -1679,6 +1678,8 @@ void BeingHandler::processBeingFakeName(Net::MessageIn &msg) msg.skip(4, "unsued"); Being *const dstBeing = createBeing2(msg, id, job, type); + if (!dstBeing) + return; dstBeing->setSubtype(fromInt(job, BeingTypeId), 0); dstBeing->setTileCoords(x, y); dstBeing->setDirection(dir); diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp index f2017bd53..d42d66b07 100644 --- a/src/net/eathena/buyingstorehandler.cpp +++ b/src/net/eathena/buyingstorehandler.cpp @@ -208,6 +208,8 @@ void BuyingStoreHandler::processBuyingStoreItemsList(Net::MessageIn &msg) const int itemType = msg.readUInt8("item type"); const int itemId = msg.readInt16("item id"); + if (!inv) + continue; const Item *const item = inv->findItem(itemId, 1); if (!item) continue; diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 015ff3c2c..86faea2e7 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -803,6 +803,8 @@ void InventoryHandler::processPlayerUseCard(Net::MessageIn &msg) for (int f = 0; f < count; f ++) { const int itemIndex = msg.readInt16("item index") - INVENTORY_OFFSET; + if (!inv) + continue; const Item *const item = inv->getItem(itemIndex); if (!item) continue; @@ -822,6 +824,8 @@ void InventoryHandler::processPlayerInsertCard(Net::MessageIn &msg) { NotifyManager::notify(NotifyTypes::CARD_INSERT_SUCCESS); Inventory *const inv = PlayerInfo::getInventory(); + if (!inv) + return; Item *const card = inv->getItem(cardIndex); int cardId = 0; if (card) -- cgit v1.2.3-70-g09d2