aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/Containers.h
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-07-19 11:59:36 +0200
committerShauren <shauren.trinity@gmail.com>2021-10-15 00:10:10 +0200
commit839d30e93bb5e865bea1d04ff8d2b2ccf2c2a964 (patch)
tree62f288ffe6e868afdee8e1cb74f7ef11ab947080 /src/common/Utilities/Containers.h
parentb638f3778877e389a7117e57885ba3e745e8393b (diff)
Common/Containers: Eliminate a edge case that could potentially lead to object invalidation.
(cherry picked from commit 64a61e03ab0799b5437ddb9fe702c4912f3f9dd9)
Diffstat (limited to 'src/common/Utilities/Containers.h')
-rw-r--r--src/common/Utilities/Containers.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/common/Utilities/Containers.h b/src/common/Utilities/Containers.h
index dfd37f69d62..ca4a00e4c29 100644
--- a/src/common/Utilities/Containers.h
+++ b/src/common/Utilities/Containers.h
@@ -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;
}