From 52147e5a9977b0ddbf547b13dbc9578b3ce9e382 Mon Sep 17 00:00:00 2001 From: Ondrej Stava Date: Thu, 11 Jun 2020 12:18:59 -0700 Subject: [PATCH] Fixed signed integer overflow (1 << num_bits) was converted to a signed integer that caused an overflow (as num_bits was usually set to 31). It worked fine since the value was later converted back to uint32_t but signed integer overflow is technically an undefined behavior and it was triggering errors in our automated tests. --- transcoder/basisu_transcoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transcoder/basisu_transcoder.cpp b/transcoder/basisu_transcoder.cpp index 056767f..558d3cf 100644 --- a/transcoder/basisu_transcoder.cpp +++ b/transcoder/basisu_transcoder.cpp @@ -3814,7 +3814,7 @@ namespace basist assert(num_bits < 32); assert(val < (1ULL << num_bits)); - uint32_t mask = (1 << num_bits) - 1; + uint32_t mask = (1ULL << num_bits) - 1; while (num_bits) {