diff mbox series

[FFmpeg-devel] libavcodec/qsvenc: fix a memory leak problem

Message ID 20220120071343.187817-1-wenbin.chen@intel.com
State Accepted
Commit 05ba0ffca9b4c28e08fdd8086218c0075537125c
Headers show
Series [FFmpeg-devel] libavcodec/qsvenc: fix a memory leak problem | expand

Checks

Context Check Description
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
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

Wenbin Chen Jan. 20, 2022, 7:13 a.m. UTC
"qf->frame" ref to input frame but it isn't released. av_frame_unref()
is added before refering qf->frame to new frame to make sure the previous
reference is released.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavcodec/qsvenc.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Xiang, Haihao Jan. 21, 2022, 1:08 a.m. UTC | #1
On Thu, 2022-01-20 at 15:13 +0800, Wenbin Chen wrote:
> "qf->frame" ref to input frame but it isn't released. av_frame_unref()
> is added before refering qf->frame to new frame to make sure the previous
> reference is released.
> 
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  libavcodec/qsvenc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 269386624d..fd5c460d68 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -1521,6 +1521,7 @@ static int submit_frame(QSVEncContext *q, const AVFrame
> *frame,
>                  return ret;
>              }
>          } else {
> +            av_frame_unref(qf->frame);
>              ret = av_frame_ref(qf->frame, frame);
>              if (ret < 0)
>                  return ret;

LGTM, will apply

-Haihao
diff mbox series

Patch

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 269386624d..fd5c460d68 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1521,6 +1521,7 @@  static int submit_frame(QSVEncContext *q, const AVFrame *frame,
                 return ret;
             }
         } else {
+            av_frame_unref(qf->frame);
             ret = av_frame_ref(qf->frame, frame);
             if (ret < 0)
                 return ret;