diff mbox series

[FFmpeg-devel] libavcodec/videotoolboxenc: fix pixel buffer memory leak

Message ID 20211109105158.9629-1-13102179620@163.com
State New
Headers show
Series [FFmpeg-devel] libavcodec/videotoolboxenc: fix pixel buffer memory leak | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

YuTong Song Nov. 9, 2021, 10:51 a.m. UTC
From: songyutong <songyutong@kuaishou.com>

In function vtenc_populate_extradata(), there is a manually created
pixel buffer that has not been released. So we should use CVPixelBufferRelease
to release this pixel buffer at the end, otherwise will cause a memory leak.
---
 libavcodec/videotoolboxenc.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Rick Kern Nov. 9, 2021, 12:23 p.m. UTC | #1
On Tue, Nov 9, 2021 at 5:57 AM Steven Liu <lingjiujianke@gmail.com> wrote:

> <13102179620@163.com> 于2021年11月9日周二 下午6:52写道:
> >
> > From: songyutong <songyutong@kuaishou.com>
> >
> > In function vtenc_populate_extradata(), there is a manually created
> > pixel buffer that has not been released. So we should use
> CVPixelBufferRelease
> > to release this pixel buffer at the end, otherwise will cause a memory
> leak.
>
Good catch. Pushed.

In the future, add your signoff to the commit message once you have
self-reviewed and tested the code. (--signoff with the git CLI).

> ---
> >  libavcodec/videotoolboxenc.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> > index 8a02d3d1a0..c06b506cc9 100644
> > --- a/libavcodec/videotoolboxenc.c
> > +++ b/libavcodec/videotoolboxenc.c
> > @@ -2548,6 +2548,7 @@ static int
> vtenc_populate_extradata(AVCodecContext   *avctx,
> >
> >
> >  pe_cleanup:
> > +    CVPixelBufferRelease(pix_buf);
> >      if(vtctx->session)
> >          CFRelease(vtctx->session);
> >
> > --
> > 2.30.0
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
>
> Test ok here, but I'm not the maintainer of this module. :D
>
>
> Thanks
> Steven
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 8a02d3d1a0..c06b506cc9 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -2548,6 +2548,7 @@  static int vtenc_populate_extradata(AVCodecContext   *avctx,
 
 
 pe_cleanup:
+    CVPixelBufferRelease(pix_buf);
     if(vtctx->session)
         CFRelease(vtctx->session);