[vlc-devel] [PATCH v3 1/2] demux: avformat: initialize i_tracks to zero

"zhilizhao(赵志立)" quinkblack at foxmail.com
Mon Jan 11 07:59:31 UTC 2021


Hi Steve,

> On Jan 11, 2021, at 2:50 PM, Steve Lhomme <robux4 at ycbcr.xyz> wrote:
> 
> I guess it's cleaner but the value is never used if tracks is not NULL. It's only temporarily unset if there is an error before tracks is allocated. Even then it's not used.
> 
> IMO a better cleaning would be to use i_tracks instead of the temporary nb_streams variable, which in the end is the same thing.

Patch 2/2 access p_sys->i_tracks in avformat_CloseDemux(), as suggested by Remi:[1]
"Should be redundant, as i_tracks ought to be 0 if tracks is NULL.”

avformat_CloseDemux() is called in multiple error cases (before and after nb_streams = ...),
i_track is uninitialized in those cases.

[1]. https://mailman.videolan.org/pipermail/vlc-devel/2021-January/141286.html

> 
> On 2021-01-04 14:11, Zhao Zhili wrote:
>> So we can use it in CloseDemux() in error path.
>> ---
>>  modules/demux/avformat/demux.c | 1 +
>>  1 file changed, 1 insertion(+)
>> diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
>> index 4a765b7352..73327cbcc5 100644
>> --- a/modules/demux/avformat/demux.c
>> +++ b/modules/demux/avformat/demux.c
>> @@ -341,6 +341,7 @@ int avformat_OpenDemux( vlc_object_t *p_this )
>>      p_sys->ic = 0;
>>      p_sys->fmt = fmt;
>>      p_sys->tracks = NULL;
>> +    p_sys->i_tracks = 0;
>>      p_sys->i_ssa_order = 0;
>>      TAB_INIT( p_sys->i_attachments, p_sys->attachments);
>>      p_sys->p_title = NULL;
>> -- 
>> 2.25.1
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list