From 839d30e93bb5e865bea1d04ff8d2b2ccf2c2a964 Mon Sep 17 00:00:00 2001 From: Treeston Date: Thu, 19 Jul 2018 11:59:36 +0200 Subject: Common/Containers: Eliminate a edge case that could potentially lead to object invalidation. (cherry picked from commit 64a61e03ab0799b5437ddb9fe702c4912f3f9dd9) --- src/common/Utilities/Containers.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/common/Utilities/Containers.h') 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; } -- cgit v1.2.3