Commit b9c17044 authored by Rafaël Carré's avatar Rafaël Carré

avformat demux: fix double free()

Allocate avformat context and set its I/O context before using it
This is the correct way to it (and is documented in avformat.h)
(cherry picked from commit c5f388e8e37f38b4526fbca379305a918dd12141)
Signed-off-by: default avatarKO Myung-Hun <komh@chollian.net>
Signed-off-by: default avatarRafaël Carré <funman@videolan.org>
parent fc4a4577
......@@ -226,15 +226,11 @@ int OpenDemux( vlc_object_t *p_this )
p_sys->io_buffer = malloc( p_sys->io_buffer_size );
#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(2<<8)+0)
AVIOContext *io = avio_alloc_context( p_sys->io_buffer,
p_sys->ic = avformat_alloc_context();
p_sys->ic->pb = avio_alloc_context( p_sys->io_buffer,
p_sys->io_buffer_size, 0, p_demux, IORead, NULL, IOSeek );
io->seekable = b_can_seek ? AVIO_SEEKABLE_NORMAL : 0;
p_sys->ic->pb->seekable = b_can_seek ? AVIO_SEEKABLE_NORMAL : 0;
error = avformat_open_input(&p_sys->ic, psz_url, p_sys->fmt, NULL);
if (error == 0)
{
p_sys->ic->flags |= AVFMT_FLAG_CUSTOM_IO;
p_sys->ic->pb = io;
}
#else
init_put_byte( &p_sys->io, p_sys->io_buffer, p_sys->io_buffer_size, 0,
p_demux, IORead, NULL, IOSeek );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment