Commit c5f388e8 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)
parent 3fc4af48
...@@ -218,15 +218,11 @@ int OpenDemux( vlc_object_t *p_this ) ...@@ -218,15 +218,11 @@ int OpenDemux( vlc_object_t *p_this )
p_sys->io_buffer = malloc( p_sys->io_buffer_size ); p_sys->io_buffer = malloc( p_sys->io_buffer_size );
#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(2<<8)+0) #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 ); 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); 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 #else
init_put_byte( &p_sys->io, p_sys->io_buffer, p_sys->io_buffer_size, 0, init_put_byte( &p_sys->io, p_sys->io_buffer, p_sys->io_buffer_size, 0,
p_demux, IORead, NULL, IOSeek ); 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