diff mbox series

[FFmpeg-devel] avcodec/texturedspenc: Fix invalid shift

Message ID DB6PR0101MB22147C98CF319A8F2BEA76808FC99@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit e92e74b89766146869f2ffe44b85b63fd39a3b66
Headers show
Series [FFmpeg-devel] avcodec/texturedspenc: Fix invalid shift | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt May 10, 2022, 4:21 p.m. UTC
Left shifts of signed types are UB unless the results fit
into the type. (Furthermore the value to be shifted need to be
nonnegative.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/texturedspenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/texturedspenc.c b/libavcodec/texturedspenc.c
index 381be16f75..21e341c613 100644
--- a/libavcodec/texturedspenc.c
+++ b/libavcodec/texturedspenc.c
@@ -181,9 +181,9 @@  static unsigned int match_colors(const uint8_t *block, ptrdiff_t stride,
     int x, y, k = 0;
     int c0_point, half_point, c3_point;
     uint8_t color[16];
-    static const int indexMap[8] = {
-        0 << 30, 2 << 30, 0 << 30, 2 << 30,
-        3 << 30, 3 << 30, 1 << 30, 1 << 30,
+    static const uint32_t indexMap[8] = {
+        0U << 30, 2U << 30, 0U << 30, 2U << 30,
+        3U << 30, 3U << 30, 1U << 30, 1U << 30,
     };
 
     /* Fill color and compute direction for each component */