[FFmpeg-cvslog] lavc/dovi_rpu: Fix UB for possible left shift of negative values

Michael Goulet git at videolan.org
Tue Jun 21 19:23:53 EEST 2022


ffmpeg | branch: master | Michael Goulet <mgoulet at fb.com> | Thu Jun 16 13:17:25 2022 +0200| [c02dd59cd302fabec60fddbaf9b7ce7a46823ff6] | committer: Thilo Borgmann

lavc/dovi_rpu: Fix UB for possible left shift of negative values

It is undefined to left-shift a negative value.

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

 libavcodec/dovi_rpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/dovi_rpu.c b/libavcodec/dovi_rpu.c
index a87562c8a3..dd38936552 100644
--- a/libavcodec/dovi_rpu.c
+++ b/libavcodec/dovi_rpu.c
@@ -172,7 +172,7 @@ static inline int64_t get_se_coef(GetBitContext *gb, const AVDOVIRpuDataHeader *
     case RPU_COEFF_FIXED:
         ipart = get_se_golomb_long(gb);
         fpart.u32 = get_bits_long(gb, hdr->coef_log2_denom);
-        return (ipart << hdr->coef_log2_denom) + fpart.u32;
+        return ipart * (1LL << hdr->coef_log2_denom) + fpart.u32;
 
     case RPU_COEFF_FLOAT:
         fpart.u32 = get_bits_long(gb, 32);



More information about the ffmpeg-cvslog mailing list