22 introduced std::map members into the CPluginEntityFactories singleton, however this introduced a case where uninstalling an entity factory would usually result in a crash. This is because in CPluginEntityFactories::RemovePluginFactory, the loop iterating through the map, if it found the factory, would erase it from the map. However, using erase on an iterator will invalidate the iterator. After erasing the element, the loop would continue and then increment from the invalidated iterator. Subsequent iterations of the loop would cause undefined behavior and eventually a crash.
This fixes the crash by adjusting the loop to advance to the iterator returned by erase, otherwise incrementing the iterator normally.
22 introduced
std::map
members into theCPluginEntityFactories
singleton, however this introduced a case where uninstalling an entity factory would usually result in a crash. This is because inCPluginEntityFactories::RemovePluginFactory
, the loop iterating through the map, if it found the factory, would erase it from the map. However, usingerase
on an iterator will invalidate the iterator. After erasing the element, the loop would continue and then increment from the invalidated iterator. Subsequent iterations of the loop would cause undefined behavior and eventually a crash.This fixes the crash by adjusting the loop to advance to the iterator returned by
erase
, otherwise incrementing the iterator normally.