From d393f41a33abc093a6a5ca1999e6c2515a86498a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Tue, 17 Jan 2012 20:55:54 +0100 Subject: [PATCH] Fix memleak after switch to encode_audio2 API. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Obviously the packet allocated by the encoder must be freed somewhere. Signed-off-by: Reimar Döffinger --- ffmpeg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index b9297df6f4..ba8dfc98fa 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1065,6 +1065,8 @@ static int encode_audio_frame(AVFormatContext *s, OutputStream *ost, exit_program(1); } + ret = pkt.size; + if (got_packet) { pkt.stream_index = ost->index; if (pkt.pts != AV_NOPTS_VALUE) @@ -1075,12 +1077,14 @@ static int encode_audio_frame(AVFormatContext *s, OutputStream *ost, write_frame(s, &pkt, ost); audio_size += pkt.size; + + av_free_packet(&pkt); } if (frame) ost->sync_opts += frame->nb_samples; - return pkt.size; + return ret; } static void do_audio_out(AVFormatContext *s, OutputStream *ost,