Fix segfault when redeeming more than four items at once

This commit is contained in:
dongresource 2021-03-06 02:09:21 +01:00
parent d5fe1cc513
commit f2b1a84ef4

View File

@ -762,10 +762,10 @@ void redeemCommand(std::string full, std::vector<std::string>& args, CNSocket* s
} }
int itemCount = ItemManager::CodeItems[code].size(); int itemCount = ItemManager::CodeItems[code].size();
int slots[4]; std::vector<int> slots;
for (int i = 0; i < itemCount; i++) { for (int i = 0; i < itemCount; i++) {
slots[i] = ItemManager::findFreeSlot(plr); slots.push_back(ItemManager::findFreeSlot(plr));
if (slots[i] == -1) { if (slots[i] == -1) {
ChatManager::sendServerMessage(sock, "/redeem: Not enough space in inventory"); ChatManager::sendServerMessage(sock, "/redeem: Not enough space in inventory");