[vlc-devel] [vlc-commits] demux: adaptive: missing es_format_Init
Francois Cartegnie
fcvlcdev at free.fr
Tue Aug 29 13:59:00 CEST 2017
Le 29/08/2017 à 13:26, Steve Lhomme a écrit :
> On Tue, Aug 29, 2017 at 11:59 AM, Francois Cartegnie <fcvlcdev at free.fr> wrote:
>> Le 29/08/2017 à 11:51, Steve Lhomme a écrit :
>>
>>>> FakeESOutID * FakeESOut::createNewID( const es_format_t *p_fmt )
>>>> {
>>>> es_format_t fmtcopy;
>>>> + es_format_Init( &fmtcopy, p_fmt->i_cat, p_fmt->i_codec );
>>>
>>> This is unneeded and has no effect. Copy() overwrites an uninitialized
>>> es_format. If it's initialized it might actually leak dynamic that are
>>> stored in it.
>>>
>>
>> I give up explaining again why Copy shouldn't be used for init.
>
> This is just what the code does and assumes everywhere. It's just doing a = b;
> If you want a to be initialized you can call Clean() in Copy(). But
> you'll have some weird behavior because in many cases that memory is
> actually uninitialized and you'll end up freeing memory pointing to
> nowhere.
That was exactly the reason of enforcing Init() prior copy() everywhere
so we could get finally rid of Init() done inside Copy() and prevent
those undefined state cases.
And since the ES changes, a = b isn't true, due to type specific
pointers. We're just recreating leaks or shared pointer because we
couldn't fix the api doing proper init use clean cycles.
Francois Cartegnie
VideoLAN - VLC Developer
More information about the vlc-devel
mailing list