[FFmpeg-devel] [PATCH] avutil/video_enc_param: fix warning
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Thu May 21 17:21:14 EEST 2020
From: Limin Wang <lance.lmwang at gmail.com>
warning: comparison is always false due to limited range of data type [-Wtype-limits]
Also nb_blocks is unsigned int, so nb_blocks * sizeof(AVVideoBlockParams) may overflow,
so force to size_t
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
libavutil/video_enc_params.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c
index c46c0f1..4a4c85f 100644
--- a/libavutil/video_enc_params.c
+++ b/libavutil/video_enc_params.c
@@ -33,8 +33,8 @@ AVVideoEncParams *av_video_enc_params_alloc(enum AVVideoEncParamsType type,
size_t size;
size = sizeof(*par);
- if (nb_blocks > SIZE_MAX / sizeof(AVVideoBlockParams) ||
- nb_blocks * sizeof(AVVideoBlockParams) > SIZE_MAX - size)
+ if (nb_blocks > UINT_MAX / sizeof(AVVideoBlockParams) ||
+ (size_t)nb_blocks * sizeof(AVVideoBlockParams) > SIZE_MAX - size)
return NULL;
size += sizeof(AVVideoBlockParams) * nb_blocks;
--
1.8.3.1
More information about the ffmpeg-devel
mailing list