From 64a78cf314379302e28ed8727c51aec82f9328a2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 21 May 2013 22:06:45 +0200 Subject: demux_lavf: workaround minor ffmpeg memory leak The sequence of avcodec_alloc_context3() / avcodec_copy_context() / avcodec_close() / av_free() leaks some memory. So don't copy the context and use it directly. Originally avcodec_copy_context() was used to guarantee that libavformat can't update the fields of the context during demuxing in order to make things a little more robust, but it's not strictly needed, and ffmpeg/ffplay don't do this anyway. Still might make the situation worse should we move demuxing into a separate thread, though. --- demux/demux_lavf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'demux/demux_lavf.c') diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 279f7f7b33..5eebffc2f9 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -423,9 +423,7 @@ static void handle_stream(demuxer_t *demuxer, int i) if (sh) { sh->codec = mp_codec_from_av_codec_id(codec->codec_id); - sh->lav_headers = avcodec_alloc_context3(codec->codec); - assert(sh->lav_headers); - avcodec_copy_context(sh->lav_headers, codec); + sh->lav_headers = codec; if (st->disposition & AV_DISPOSITION_DEFAULT) sh->default_track = 1; -- cgit v1.2.3