[vlc-devel] [PATCH 2/6] avformat: fix memory leak

Hannes Domani ssbssa at yahoo.de
Thu Aug 27 16:18:22 CEST 2015


---
 modules/demux/avformat/demux.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 197946a..fd4359b 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -271,7 +271,7 @@ int OpenDemux( vlc_object_t *p_this )
     p_sys->io_buffer = av_malloc( p_sys->io_buffer_size );
 
     p_sys->ic = avformat_alloc_context();
-    p_sys->ic->pb = avio_alloc_context( p_sys->io_buffer,
+    AVIOContext *pb = p_sys->ic->pb = avio_alloc_context( p_sys->io_buffer,
         p_sys->io_buffer_size, 0, p_demux, IORead, NULL, IOSeek );
     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);
@@ -280,6 +280,7 @@ int OpenDemux( vlc_object_t *p_this )
     {
         msg_Err( p_demux, "Could not open %s: %s", psz_url,
                  vlc_strerror_c(AVUNERROR(error)) );
+        av_free( pb );
         p_sys->ic = NULL;
         free( psz_url );
         CloseDemux( p_this );
-- 
2.5.0



More information about the vlc-devel mailing list