[FFmpeg-devel] [PATCH v4 2/3] avformat/tee: Fix leaks in tee muxer when open_slave fails

Jan Sebechlebsky sebechlebskyjan at gmail.com
Fri Apr 8 12:56:10 CEST 2016


On 04/07/2016 12:28 AM, Marton Balint wrote:
>
> On Mon, 4 Apr 2016, sebechlebskyjan at gmail.com wrote:
>
>> From: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
>>
>> Calling close_slave in case error is to be returned from open_slave
>> will free allocated resources.
>>
>> Since failure can happen before bsfs array is initialized,
>> close_slave must check that bsfs is not NULL before accessing
>> tee_slave->bsfs[i] element.
>
> I noticed a problem. tee->nb_slaves is only assigned after opening all 
> slaves, so if any of the open_slave call fails, tee->nb_slaves will 
> still be 0, so no resources will get freed.
>
> On the other hand, if you move the assignment before the open_slave 
> loop, you will also have to handle the case in close_slaves when 
> tee_slave->avf is null, or you have to increase tee->nb_slaves 
> incrementally in the loop...
>
> Regards,
> Marton
Thanks, this is another thing I overlooked when I was splitting the 
changes in 3 commits. Actually in third patch tee->nb_slaves is assigned 
before open_slave loop. I'll fix it to have stable version after each 
single patch.

Have a nice day

Jan S.


More information about the ffmpeg-devel mailing list