Skip to content

Commit

Permalink
fix: crash getItems (mehah#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
luanluciano93 authored Oct 5, 2024
1 parent 9aaa3ef commit e54cb1c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/client/protocolgameparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1369,10 +1369,11 @@ void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
}

const uint8_t itemCount = msg->getU8();
std::vector<ItemPtr> items(itemCount);
std::vector<ItemPtr> items;
items.reserve(itemCount);

for (auto i = 0; i < itemCount; i++) {
items[i] = getItem(msg);
items.push_back(getItem(msg));
}

if (g_game.getFeature(Otc::GameContainerFilter)) {
Expand Down Expand Up @@ -1556,9 +1557,10 @@ void ProtocolGame::parseOwnTrade(const InputMessagePtr& msg)

const uint8_t count = msg->getU8();
std::vector<ItemPtr> items;
items.reserve(count);

for (auto i = 0; i < count; i++) {
items[i] = getItem(msg);
items.push_back(getItem(msg));
}

g_game.processOwnTrade(name, items);
Expand All @@ -1570,9 +1572,10 @@ void ProtocolGame::parseCounterTrade(const InputMessagePtr& msg)

const uint8_t count = msg->getU8();
std::vector<ItemPtr> items;
items.reserve(count);

for (auto i = 0; i < count; i++) {
items[i] = getItem(msg);
items.push_back(getItem(msg));
}

g_game.processCounterTrade(name, items);
Expand Down Expand Up @@ -4779,6 +4782,7 @@ void ProtocolGame::parseImbuementWindow(const InputMessagePtr& msg)

const uint32_t neededItemsListCount = msg->getU32();
std::vector<ItemPtr> neededItemsList;
neededItemsList.reserve(neededItemsListCount);

for (uint32_t i = 0; i < neededItemsListCount; ++i) {
const uint16_t needItemId = msg->getU16();
Expand Down

0 comments on commit e54cb1c

Please sign in to comment.