[FFmpeg-devel] [PATCH 1/3] libavutil: AVEncodeInfo data structures
Juan De León
juandl at google.com
Fri Aug 23 21:45:08 EEST 2019
On Fri, Aug 23, 2019 at 8:07 AM Nicolas George <george at nsup.org> wrote:
> > + if (nb_blocks - 1 > (SIZE_MAX - sizeof(AVEncodeInfoFrame)) /
> sizeof(AVEncodeInfoBlock))
> > + return NULL;
>
> nb_blocks - 1 overflows for 0. Move the -1 right of the = as +1.
>
> > + //AVEncodeInfoFrame already allocates size for one element of
> AVEncodeInfoBlock
>
> > + size_t size = sizeof(AVEncodeInfoFrame) - sizeof(AVEncodeInfoBlock)
> +
> > + FFMAX(1, nb_blocks) * sizeof(AVEncodeInfoBlock);
>
> This code would be better shared in an inline function or macro instead
> of duplicated. With a macro, you can include the check.
>
I changed it to an inline function, returns SIZE_MAX if it fails to make
av_malloc() fail and return NULL.
Thanks for the feedback.
More information about the ffmpeg-devel
mailing list