Skip to content

Commit

Permalink
[Crash] null pointer check to avoid unexpected behavior (opentibiabr#664
Browse files Browse the repository at this point in the history
)

With this check, we avoid a crash by sending the null "Item*" (first variable) to the "internalRemoveItem" function.
  • Loading branch information
carlospess0a authored Dec 8, 2022
1 parent eed2c44 commit 81cf1f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,10 @@ ReturnValue Game::internalAddItem(Cylinder* toCylinder, Item* item, int32_t inde

ReturnValue Game::internalRemoveItem(Item* item, int32_t count /*= -1*/, bool test /*= false*/, uint32_t flags /*= 0*/)
{
if (item == nullptr) {
SPDLOG_DEBUG("{} - Item is nullptr", __FUNCTION__);
return RETURNVALUE_NOTPOSSIBLE;
}
Cylinder* cylinder = item->getParent();
if (cylinder == nullptr) {
SPDLOG_DEBUG("{} - Cylinder is nullptr", __FUNCTION__);
Expand Down

0 comments on commit 81cf1f5

Please sign in to comment.