On Thu, May 21, 2020 at 04:34:39PM +0200, Nicolas George wrote: > lance.lmw...@gmail.com (12020-05-21): > > From: Limin Wang <lance.lmw...@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 > > No it may not, the test just before prevents it. > > > > > Signed-off-by: Limin Wang <lance.lmw...@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) || > > + if (nb_blocks > UINT_MAX / sizeof(AVVideoBlockParams) || > > These tests are not equivalent. I'm not sure, Mac compile give below warning:
warning: comparison of constant 922337203685477580 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare] > > > - nb_blocks * sizeof(AVVideoBlockParams) > SIZE_MAX - size) > > + (size_t)nb_blocks * sizeof(AVVideoBlockParams) > SIZE_MAX - size) > > The cast is unnecessary due to C's promotion rules. Yes, It seems it's not necessary as the first test. > > > return NULL; > > size += sizeof(AVVideoBlockParams) * nb_blocks; > > > > Regards, > > -- > Nicolas George -- Thanks, Limin Wang _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".