[FFmpeg-devel] [PATCH] lavformat/utils: Fix a memleak that st->codec->hw_frames_ctx
Chao Liu
chaox.a.liu at gmail.com
Fri Jan 20 11:35:33 EET 2017
Have you ever used valgrind? Please just run the command below:
valgrind --leak-check=full --log-file=out.log ffmpeg -hwaccel qsv
-qsv_device /dev/dri/renderD128 -c:v h264_qsv -i a.h264 -c:v h264_qsv -b:v
2M -y out.h264
See line 3323 of ffmpeg.c,
ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx);
and see what have been done in avcodec_copy_context:
if (src->hw_frames_ctx) {
dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);
if (!dest->hw_frames_ctx)
goto fail;
}
However, that is not freed when calling avformat_free_context.
On Fri, Jan 20, 2017 at 4:47 PM, wm4 <nfxjfg at googlemail.com> wrote:
> On Fri, 20 Jan 2017 10:06:50 +0800
> "Huang, Zhengxu" <zhengxu.maxwell at gmail.com> wrote:
>
> > From 9ceb2ac6a89246f2e686eb3ad3448fbaff5328f7 Mon Sep 17 00:00:00 2001
> > From: Zhengxu <zhengxu.maxwell at gmail.com>
> > Date: Fri, 13 Jan 2017 10:33:05 +0800
> > Subject: [PATCH] lavformat/utils: Fix a memleak that
> st->codec->hw_frames_ctx
> > is not released.
> >
> > Signed-off-by: ChaoX A Liu <chaox.a.liu at gmail.com>
> > Signed-off-by: Huang, Zhengxu <zhengxu.maxwell at gmail.com>
> > Signed-off-by: Andrew, Zhang <huazh407 at gmail.com>
> > ---
> > libavformat/utils.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index d5dfca7..cadec15 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -4127,6 +4127,7 @@ static void free_stream(AVStream **pst)
> > FF_DISABLE_DEPRECATION_WARNINGS
> > av_freep(&st->codec->extradata);
> > av_freep(&st->codec->subtitle_header);
> > + av_buffer_unref(&st->codec->hw_frames_ctx);
> > av_freep(&st->codec);
> > FF_ENABLE_DEPRECATION_WARNINGS
> > #endif
>
> What triggers this? In a sane world this should never ever happen.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list