[FFmpeg-devel] [PATCH v5] lavf/matroskadec: Normalize noncompliant A_QUICKTIME/V_QUICKTIME private data

Mats Peterson matsp888 at yahoo.com
Mon Jan 11 03:53:48 CET 2016


On 01/11/2016 01:46 AM, Michael Niedermayer wrote:
> On Sun, Jan 10, 2016 at 04:04:47AM +0100, Mats Peterson wrote:
>> How about this one, Michael? Rather than using the obviously
>> dangerous av_realloc() it uses av_malloc() to allocate new memory
>> for the private data, then copies the private data to it, frees the
>> pointer to the original private data, and finally sets
>> track->codec->priv_data to the newly allocated memory.
>
> that documentation is misleading, av_malloc() is if one is really
> pedantic not safe to be passed to av_free or av_realloc()
> if one isnt pedantic it safe to be passed to both
>
> but of course theres nothing wrong with seperating them if you want
> to seperate them in your code. Theres a small theretical chance that
> some future platform will not work with mixed aligned memory and
> realloc but would be able to mix both with free()
>
> patch applied
>
> thanks


Thanks, Michael. But I don't understand what you mean here. Is it *my* 
documentation that is misleading? I said that av_realloc() is dangerous 
because of the fact that the allocation of the binary data in 
matroskadec.c is done with av_fast_padded_malloc(), which in turn uses 
av_malloc(), and which might use memalign(), of which the pointer is 
apparently not safe to pass to av_malloc(), according to the FFmpeg 
documentation.

What do you mean by "separating them" by the way? I haven't separated 
anything as far as I know.

Mats



More information about the ffmpeg-devel mailing list