vlc/vlc-2.0 | branch: master | Rafaël Carré <[email protected]> | 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 <[email protected]>
Signed-off-by: Rafaël Carré <[email protected]>

> 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 );

_______________________________________________
vlc-commits mailing list
[email protected]
http://mailman.videolan.org/listinfo/vlc-commits

Reply via email to