]> granicus.if.org Git - libvpx/commitdiff
fdct4x4_test: fix unsigned overflow
authorJames Zern <jzern@google.com>
Thu, 9 Jun 2016 00:29:02 +0000 (17:29 -0700)
committerJames Zern <jzern@google.com>
Thu, 9 Jun 2016 00:29:02 +0000 (17:29 -0700)
the difference between src and dst will be signed, the error will be
unsigned.
quiets -fsanitize=integer:
unsigned integer overflow: 4294967295 * 4294967295

Change-Id: I502fd707823c4faaa7f587c9cc0312f057e04904

test/fdct4x4_test.cc

index 5a58830d56c38d81ab462be323ec0134112f0867..735cccf8dca9aead41de2c16aafbe2de9def3091 100644 (file)
@@ -141,11 +141,11 @@ class Trans4x4TestBase {
 
       for (int j = 0; j < kNumCoeffs; ++j) {
 #if CONFIG_VP9_HIGHBITDEPTH
-        const uint32_t diff =
+        const int diff =
             bit_depth_ == VPX_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
 #else
         ASSERT_EQ(VPX_BITS_8, bit_depth_);
-        const uint32_t diff = dst[j] - src[j];
+        const int diff = dst[j] - src[j];
 #endif
         const uint32_t error = diff * diff;
         if (max_error < error)
@@ -258,10 +258,10 @@ class Trans4x4TestBase {
 
       for (int j = 0; j < kNumCoeffs; ++j) {
 #if CONFIG_VP9_HIGHBITDEPTH
-        const uint32_t diff =
+        const int diff =
             bit_depth_ == VPX_BITS_8 ? dst[j] - src[j] : dst16[j] - src16[j];
 #else
-        const uint32_t diff = dst[j] - src[j];
+        const int diff = dst[j] - src[j];
 #endif
         const uint32_t error = diff * diff;
         EXPECT_GE(static_cast<uint32_t>(limit), error)