[FFmpeg-devel] [PATCH] avformat: Add check for ff_get_extradata

Paul B Mahol onemda at gmail.com
Tue Feb 22 11:30:04 EET 2022


On Tue, Feb 22, 2022 at 10:14 AM Jiasheng Jiang <jiasheng at iscas.ac.cn>
wrote:

> On Tue, Feb 22, 2022 at 04:10:51PM +0800, Paul B Mahol wrote:
>
> >> As the potential failure of the memory allocation, the
> ff_get_extradata()
> >> could return error if fails.
> >> Therefore, it should be better to deal with the return value of the
> >> ff_get_extradata() and return error if fails.
> >>
> >
> >
> > Not really necessary. Does not fix anything.
>
> It is true that the 'extradata' could be NULL and have not used.
> But I have checked many other callers of the ff_get_extradata(),
> such as avi_read_header() in `libavformat/avidec.c`.
> They all have checked the return value to guarantee the 'extradata'
> to be non-NULL.
> That means in the future, if the 'aix->extradata' is used, the programmer
> may not notice that 'aix->extradata' is especial and needs to be checked
> before use.
> Therefore, I think it is necessary to add the check to guarantee the
> consisitency of the code.
>

Nope, that does not make sense, it should always be checked.


>
> Thanks,
> Jiang
>
>


More information about the ffmpeg-devel mailing list