Common/Containers: Eliminate a edge case that could potentially lead to object invalidation.

(cherry picked from commit 64a61e03ab)
This commit is contained in:
Treeston
2018-07-19 11:59:36 +02:00
committed by Shauren
parent b638f37788
commit 839d30e93b

View File

@@ -68,7 +68,8 @@ namespace Trinity
// this element has chance (elementsToKeep / elementsToProcess) of being kept
if (urand(1, elementsToProcess) <= elementsToKeep)
{
*keepIt = std::move(*curIt);
if (keepIt != curIt)
*keepIt = std::move(*curIt);
++keepIt;
--elementsToKeep;
}