[FFmpeg-devel] [PATCH v0 02/14] avcodec: move AVCodecInternal allocation to avcodec_alloc_context3

James Almer jamrial at gmail.com
Fri Mar 24 15:02:40 EET 2023


On 3/24/2023 9:07 AM, Andreas Rheinhardt wrote:
>> @@ -174,6 +190,8 @@ void avcodec_free_context(AVCodecContext **pavctx)
>>   
>>       avcodec_close(avctx);
>>   
>> +    av_freep(&avctx->internal);
> Moving this to avcodec_free_context() creates a leak when using
> avcodec_close()+av_free(). This can be fixed by allocating the
> AVCodecContext and the AVCodecInternal jointly.

Can't we just declare that doing av_free() on a AVCodecContext is not a 
valid API usage? Every other struct with an specific free function is 
very clear about it being the only way to free them.

> 
>> +
>>       av_freep(&avctx->extradata);
>>       av_freep(&avctx->subtitle_header);
>>       av_freep(&avctx->intra_matrix);


More information about the ffmpeg-devel mailing list