[FFmpeg-cvslog] lavc/r210enc: Fix undefined behaviour encoding r10k.

Carl Eugen Hoyos git at videolan.org
Sun Aug 11 03:07:59 EEST 2019


ffmpeg | branch: master | Carl Eugen Hoyos <ceffmpeg at gmail.com> | Mon Jul  1 13:06:02 2019 +0200| [2828f5b0d8e432ccd686e3c28ff68348d8a45f7e] | committer: Carl Eugen Hoyos

lavc/r210enc: Fix undefined behaviour encoding r10k.

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.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2828f5b0d8e432ccd686e3c28ff68348d8a45f7e
---

 libavcodec/r210enc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c
index 02412f3684..b24dc1a358 100644
--- a/libavcodec/r210enc.c
+++ b/libavcodec/r210enc.c
@@ -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



More information about the ffmpeg-cvslog mailing list