[FFmpeg-devel] [PATCH] avcodec/hevc_ps: Fix UB 1 << 31

Tomas Härdin git at haerdin.se
Sat Jun 1 18:01:06 EEST 2024


lör 2024-06-01 klockan 15:13 +0200 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/hevc_ps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index 7b486ce0af..1a459ad054 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -200,7 +200,7 @@ int ff_hevc_decode_short_term_rps(GetBitContext
> *gb, AVCodecContext *avctx,
>          }
>  
>          for (unsigned i = 0; i < FF_ARRAY_ELEMS(used); i++)
> -            rps->used |= used[i] * (1 << i);
> +            rps->used |= used[i] * (1U << i);

Why not just (uint32_t)used[i] << i?

/Tomas


More information about the ffmpeg-devel mailing list