mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
Common/Containers: Eliminate a edge case that could potentially lead to object invalidation.
(cherry picked from commit 64a61e03ab)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user