[vlc-devel] [PATCH 10/15] avformat demux: fix double free()
KO Myung-Hun
komh78 at gmail.com
Fri Mar 2 16:03:07 CET 2012
From: Rafaël Carré <funman at videolan.org>
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>
---
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 );
--
1.7.3.2
More information about the vlc-devel
mailing list