entitylump: Fix behavior of append (#1836)

This change ensures that the iterator values used by `std::distance`
is correct.  Having the emplace within leads to the possibility of
`m_Entities.begin()` being invalidated due to reallocations.
This commit is contained in:
nosoop 2022-09-20 07:24:08 -07:00 committed by GitHub
parent 568da23c96
commit 855ece1d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,10 +122,8 @@ void EntityLumpManager::Insert(size_t index) {
}
size_t EntityLumpManager::Append() {
return std::distance(
m_Entities.begin(),
m_Entities.emplace(m_Entities.end(), std::make_shared<EntityLumpEntry>())
);
auto it = m_Entities.emplace(m_Entities.end(), std::make_shared<EntityLumpEntry>());
return std::distance(m_Entities.begin(), it);
}
size_t EntityLumpManager::Length() {