[FFmpeg-cvslog] lavc/hevc_ps: fix variable signedness in ff_hevc_decode_short_term_rps()

Anton Khirnov git at videolan.org
Fri May 31 20:32:39 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Apr 10 13:36:50 2024 +0200| [4264e4056c41e0dfc01a27d95f600ac91fb5a04f] | committer: Anton Khirnov

lavc/hevc_ps: fix variable signedness in ff_hevc_decode_short_term_rps()

It is actually supposed to go negative in the loop over num_negative
pics, but underflow does not break anything as the result is then
assigned to a signed int.

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

 libavcodec/hevc_ps.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 1af691414e..d90f172c46 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -197,7 +197,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
             }
         }
     } else {
-        unsigned int prev, nb_positive_pics;
+        unsigned int nb_positive_pics;
+
         rps->num_negative_pics = get_ue_golomb_long(gb);
         nb_positive_pics       = get_ue_golomb_long(gb);
 
@@ -209,7 +210,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
 
         rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics;
         if (rps->num_delta_pocs) {
-            prev = 0;
+            int prev = 0;
+
             for (i = 0; i < rps->num_negative_pics; i++) {
                 delta_poc = rps->delta_poc_s0[i] = get_ue_golomb_long(gb) + 1;
                 if (delta_poc < 1 || delta_poc > 32768) {



More information about the ffmpeg-cvslog mailing list