diff mbox series

[FFmpeg-devel,v2] avutils/video_enc_params: fix type-limits compile warning on 64 bits build system

Message ID 20210214164121.30100-1-nuomi2021@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2] avutils/video_enc_params: fix type-limits compile warning on 64 bits build system
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Nuo Mi Feb. 14, 2021, 4:41 p.m. UTC
This will fix following compile warning:

    libavutil/video_enc_params.c: In function ‘av_video_enc_params_alloc:                                                                                                                                                                     libavutil/video_enc_params.c:36:19: warning: comparison is always false due to limited range of data type [-Wtype-limits]                                                                                                                       36 |     if (nb_blocks > SIZE_MAX / sizeof(AVVideoBlockParams) ||                                                                                                                                                                               |                   ^
---
 libavutil/video_enc_params.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c
index c46c0f1dc6..2606b5589a 100644
--- a/libavutil/video_enc_params.c
+++ b/libavutil/video_enc_params.c
@@ -33,7 +33,11 @@  AVVideoEncParams *av_video_enc_params_alloc(enum AVVideoEncParamsType type,
     size_t size;
 
     size = sizeof(*par);
-    if (nb_blocks > SIZE_MAX / sizeof(AVVideoBlockParams) ||
+    if (
+#if SIZE_MAX <= UINT_MAX
+        //check the overflow
+        nb_blocks > SIZE_MAX / sizeof(AVVideoBlockParams) ||
+#endif
         nb_blocks * sizeof(AVVideoBlockParams) > SIZE_MAX - size)
         return NULL;
     size += sizeof(AVVideoBlockParams) * nb_blocks;