mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-12-24 19:58:37 +01:00
Added buffer size check while populating it.
This commit is contained in:
parent
0b134e98a9
commit
7853451b01
1 changed files with 10 additions and 4 deletions
|
@ -144,17 +144,23 @@ bool GetResultItems( SteamInventoryResult_t resultHandle,
|
|||
|
||||
if (pOutItemsArray != nullptr)
|
||||
{
|
||||
for (auto& i : items)
|
||||
uint32 max_items = *punOutItemsArraySize;
|
||||
// We end if we reached the end of items or the end of buffer
|
||||
for( auto i = items.begin(); i != items.end() && max_items; ++i, --max_items )
|
||||
{
|
||||
pOutItemsArray->m_iDefinition = i.first;
|
||||
pOutItemsArray->m_itemId = i.first;
|
||||
pOutItemsArray->m_iDefinition = i->first;
|
||||
pOutItemsArray->m_itemId = i->first;
|
||||
pOutItemsArray->m_unQuantity = 1;
|
||||
pOutItemsArray->m_unFlags = k_ESteamItemNoTrade;
|
||||
++pOutItemsArray;
|
||||
}
|
||||
*punOutItemsArraySize = std::min(*punOutItemsArraySize, static_cast<uint32>(items.size()));
|
||||
}
|
||||
else if (punOutItemsArraySize != nullptr)
|
||||
{
|
||||
*punOutItemsArraySize = items.size();
|
||||
}
|
||||
|
||||
if (punOutItemsArraySize)* punOutItemsArraySize = items.size();
|
||||
PRINT_DEBUG("GetResultItems good\n");
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue