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

Rafaël Carré git at videolan.org
Sun Mar 4 22:42:03 CET 2012


vlc/vlc-2.0 | branch: master | Rafaël Carré <funman at videolan.org> | Sat Mar  3 00:03:07 2012 +0900| [b9c17044e4108e71cdd6d2b5e50ea28f2180cc34] | 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)
(cherry picked from commit c5f388e8e37f38b4526fbca379305a918dd12141)

Signed-off-by: KO Myung-Hun <komh at chollian.net>
Signed-off-by: Rafaël Carré <funman at videolan.org>

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

 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 6fa109b..3264b11 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -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 );



More information about the vlc-commits mailing list