[vlc-commits] avformat: Fix potential double free

Hannes Domani ssbssa at yahoo.de
Thu Sep 7 12:32:51 CEST 2017


Hugo Beauzée-Luyssen <git at videolan.org> schrieb am 10:08 Donnerstag, 7.September 2017:

> avformat: Fix potential double free
> avformat seems to take the ownership of this buffer, but it also seems
> not to sometimes.
> This does introduce a leak , but keeping it there definitely causes
> crashes some other times.
> If someone understands avformat/avio APIs, opinion welcome.

The documentation for avio_alloc_context() states (https://www.ffmpeg.org/doxygen/2.5/avio_8h.html#a853f5149136a27ffba3207d8520172a5):

Memory block for input/output operations via AVIOContext.
The buffer must be allocated with av_malloc() and friends.
It may be freed and replaced with a new buffer by libavformat.
AVIOContext.buffer holds the buffer currently in use, which must be later freed with av_free()

So it should be:
- av_free( p_io_buffer );

+ av_free( pb->buffer );

And I'm aware that I introduced the wrong av_free() line:

More information about the vlc-devel mailing list