From eb58ba5657b7b6a241a4be245df35dc0d06cb72c Mon Sep 17 00:00:00 2001 From: Monty Montgomery Date: Wed, 23 Apr 2025 10:10:23 -0400 Subject: [PATCH] Fix to sanity checking of ElementMap::restore() An operator precedence error in new sanity checking code within ElementMap::restore() causes .Shape.Map.txt files with more than 2 element maps to be rejected as invalid. This silently corrupts projects upon loading, potentially unrecoverably. The preexisting code comment is still appropriate if ironic. --- src/App/ElementMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App/ElementMap.cpp b/src/App/ElementMap.cpp index 88cdcde128..54d6a3527e 100644 --- a/src/App/ElementMap.cpp +++ b/src/App/ElementMap.cpp @@ -258,7 +258,7 @@ ElementMapPtr ElementMap::restore(::App::StringHasherRef hasherRef, std::istream std::vector childMaps; count = 0; - constexpr int practicalMaximum {1 << 30 / sizeof(ElementMapPtr)}; // a 1GB child map vector: almost certainly a bug + constexpr int practicalMaximum {(1 << 30) / sizeof(ElementMapPtr)}; // a 1GB child map vector: almost certainly a bug if (!(stream >> tmp >> count) || tmp != "MapCount" || count == 0 || count > practicalMaximum) { FC_THROWM(Base::RuntimeError, msg); // NOLINT }