From 8028cbbe39953c238a2a32d14bb0b17e4c9033df Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Thu, 20 May 2021 20:41:30 -0500 Subject: [PATCH] Fixed issue where the SettingsRegistryImpl::LessThan function would set the collisionFound boolean to true when comparing two elements that happened to be at the same address via std::sort. (#857) In reality there is no such collision and the comparisons needs to early return with false, but not change the collisionFound flag. --- .../AzCore/AzCore/Settings/SettingsRegistryImpl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryImpl.cpp b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryImpl.cpp index 2421c75be3..dbd8df4df1 100644 --- a/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryImpl.cpp +++ b/Code/Framework/AzCore/AzCore/Settings/SettingsRegistryImpl.cpp @@ -880,6 +880,13 @@ namespace AZ const Specializations& specializations, const rapidjson::Pointer& historyPointer, AZStd::string_view folderPath) { using namespace rapidjson; + + if (&lhs == &rhs) + { + // Early return to avoid setting the collisionFound reference to true + // std::sort is allowed to pass in the same memory address for the left and right elements + return false; + } AZ_Assert(!lhs.m_tags.empty(), "Comparing a settings file without at least a name tag."); AZ_Assert(!rhs.m_tags.empty(), "Comparing a settings file without at least a name tag.");