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

Jiasheng Jiang jiasheng at iscas.ac.cn
Tue Feb 22 11:14:46 EET 2022


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.

Thanks,
Jiang



More information about the ffmpeg-devel mailing list