]> git.sesse.net Git - ffmpeg/commitdiff
lavc/r210enc: Fix undefined behaviour encoding r10k.
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>
Mon, 1 Jul 2019 11:06:02 +0000 (13:06 +0200)
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>
Sun, 11 Aug 2019 00:06:44 +0000 (02:06 +0200)
Fixes the following ubsan error:
libavcodec/r210enc.c:69:28: runtime error: left shift of 522 by 22 places cannot be represented in type 'int'

Fixes ticket #7982.

libavcodec/r210enc.c

index 02412f3684a91df04e2374c93412f1b220d63bb5..b24dc1a358782a9e42e676c2f04b6d997f88070c 100644 (file)
@@ -60,9 +60,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         uint16_t *srcb = (uint16_t *)srcb_line;
         for (j = 0; j < avctx->width; j++) {
             uint32_t pixel;
-            uint16_t r = *srcr++;
-            uint16_t g = *srcg++;
-            uint16_t b = *srcb++;
+            unsigned r = *srcr++;
+            unsigned g = *srcg++;
+            unsigned b = *srcb++;
             if (avctx->codec_id == AV_CODEC_ID_R210)
                 pixel = (r << 20) | (g << 10) | b;
             else