Skip to content

Commit

Permalink
fix: remove empty if block and prevent use of pointer after erase
Browse files Browse the repository at this point in the history
This removes an empty if block that was kept for legacy purposes but no longer serves any functional purpose. Additionally, it addresses the improper use of the container pointer after the iterator it is erased from the openContainers structure, which could lead to undefined behavior and crashes.

Changes made:

• Removed the empty block if (container && container->getID() == ITEM_BROWSEFIELD) { }, which was no longer needed.

• Stored the value of container in a temporary variable before erasing the iterator it from the openContainers map.

These changes improve code stability, prevent potential crashes, and make the code cleaner by removing unnecessary logic.
  • Loading branch information
dudantas committed Nov 10, 2024
1 parent d13c445 commit f56d8d8
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,6 @@ void Player::closeContainer(uint8_t cid) {
removeEmptyRewards();
}
openContainers.erase(it);
if (container && container->getID() == ITEM_BROWSEFIELD) {
}
}

void Player::removeEmptyRewards() {
Expand Down

0 comments on commit f56d8d8

Please sign in to comment.