From 9a6cdd1ba3bd6fe592761dc7e9e6b5273495d048 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 21 Oct 2022 19:54:27 +0200 Subject: [PATCH] avutil/integer: Fix undefined left shifts of negative numbers Affected the integers FATE-test. Signed-off-by: Andreas Rheinhardt --- libavutil/integer.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libavutil/integer.c b/libavutil/integer.c index b709c6d487..3bc33dbca2 100644 --- a/libavutil/integer.c +++ b/libavutil/integer.c @@ -103,7 +103,7 @@ AVInteger av_shr_i(AVInteger a, int s){ for(i=0; i>4); unsigned int v=0; - if(index+1> (s&15); } @@ -158,11 +158,9 @@ AVInteger av_int2i(int64_t a){ } int64_t av_i2int(AVInteger a){ - int i; - int64_t out=(int8_t)a.v[AV_INTEGER_SIZE-1]; + uint64_t out = a.v[3]; - for(i= AV_INTEGER_SIZE-2; i>=0; i--){ + for (int i = 2; i >= 0; i--) out = (out<<16) + a.v[i]; - } return out; }