summaryrefslogtreecommitdiff
path: root/thirdparty/glslang/SPIRV/SPVRemapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/glslang/SPIRV/SPVRemapper.cpp')
-rw-r--r--thirdparty/glslang/SPIRV/SPVRemapper.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/thirdparty/glslang/SPIRV/SPVRemapper.cpp b/thirdparty/glslang/SPIRV/SPVRemapper.cpp
index 1adc6a3042..56d7f431a7 100644
--- a/thirdparty/glslang/SPIRV/SPVRemapper.cpp
+++ b/thirdparty/glslang/SPIRV/SPVRemapper.cpp
@@ -830,7 +830,15 @@ namespace spv {
[&](spv::Id& id) {
if (thisOpCode != spv::OpNop) {
++idCounter;
- const std::uint32_t hashval = opCounter[thisOpCode] * thisOpCode * 50047 + idCounter + fnId * 117;
+ const std::uint32_t hashval =
+ // Explicitly cast operands to unsigned int to avoid integer
+ // promotion to signed int followed by integer overflow,
+ // which would result in undefined behavior.
+ static_cast<unsigned int>(opCounter[thisOpCode])
+ * thisOpCode
+ * 50047
+ + idCounter
+ + static_cast<unsigned int>(fnId) * 117;
if (isOldIdUnmapped(id))
localId(id, nextUnusedId(hashval % softTypeIdLimit + firstMappedID));