[vlc-commits] avformat demux: fix double free()

Rafaël Carré git at videolan.org
Sun Jan 29 09:47:53 CET 2012


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Sun Jan 29 03:38:08 2012 -0500| [c5f388e8e37f38b4526fbca379305a918dd12141] | committer: 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)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c5f388e8e37f38b4526fbca379305a918dd12141
---

 modules/demux/avformat/demux.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 73fa476..d346f0f 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -218,15 +218,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 );



More information about the vlc-commits mailing list