diff mbox

[FFmpeg-devel,v1,1/1] vaapi_hevc: Fix double-free issue.

Message ID 1553160583-14557-1-git-send-email-decai.lin@intel.com
State New
Headers show

Commit Message

Decai Lin March 21, 2019, 9:29 a.m. UTC
From: "Yan, FengX" <fengx.yan@intel.com>

Signed-off-by: Yan, FengX <fengx.yan@intel.com>
Signed-off-by: Decai Lin <decai.lin@intel.com>
---
 libavcodec/vaapi_hevc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Fu, Linjie March 21, 2019, 12:19 p.m. UTC | #1
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Decai Lin

> Sent: Thursday, March 21, 2019 17:30

> To: ffmpeg-devel@ffmpeg.org

> Cc: Yan, FengX <fengx.yan@intel.com>; Lin, Decai <decai.lin@intel.com>

> Subject: [FFmpeg-devel] [PATCH v1 1/1] vaapi_hevc: Fix double-free issue.

> 

> From: "Yan, FengX" <fengx.yan@intel.com>

> 

> Signed-off-by: Yan, FengX <fengx.yan@intel.com>

> Signed-off-by: Decai Lin <decai.lin@intel.com>

> ---

>  libavcodec/vaapi_hevc.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c

> index 19aabcd..373ffc4 100644

> --- a/libavcodec/vaapi_hevc.c

> +++ b/libavcodec/vaapi_hevc.c

> @@ -271,7 +271,7 @@ static int vaapi_hevc_end_frame(AVCodecContext

> *avctx)

> 

>      ret = ff_vaapi_decode_issue(avctx, &pic->pic);

>      if (ret < 0)

> -        goto fail;

> +        return ret;

> 

>      return 0;

>  fail:


I believe this should match the behavior in vaapi_h264/mpeg4/.../vc1.c,
and remove the redundant  ff_vaapi_decode_cancel in vaapi_hevc_end_frame().

--Linjie
Decai Lin March 22, 2019, 6:40 a.m. UTC | #2
> -----Original Message-----

> From: Fu, Linjie

> Sent: 2019年3月21日 20:20

> To: FFmpeg development discussions and patches

> <ffmpeg-devel@ffmpeg.org>

> Cc: Yan, FengX <fengx.yan@intel.com>; Lin, Decai <decai.lin@intel.com>

> Subject: RE: [FFmpeg-devel] [PATCH v1 1/1] vaapi_hevc: Fix double-free

> issue.

> 

> > -----Original Message-----

> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> > Of Decai Lin

> > Sent: Thursday, March 21, 2019 17:30

> > To: ffmpeg-devel@ffmpeg.org

> > Cc: Yan, FengX <fengx.yan@intel.com>; Lin, Decai <decai.lin@intel.com>

> > Subject: [FFmpeg-devel] [PATCH v1 1/1] vaapi_hevc: Fix double-free issue.

> >

> > From: "Yan, FengX" <fengx.yan@intel.com>

> >

> > Signed-off-by: Yan, FengX <fengx.yan@intel.com>

> > Signed-off-by: Decai Lin <decai.lin@intel.com>

> > ---

> >  libavcodec/vaapi_hevc.c | 2 +-

> >  1 file changed, 1 insertion(+), 1 deletion(-)

> >

> > diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index

> > 19aabcd..373ffc4 100644

> > --- a/libavcodec/vaapi_hevc.c

> > +++ b/libavcodec/vaapi_hevc.c

> > @@ -271,7 +271,7 @@ static int vaapi_hevc_end_frame(AVCodecContext

> > *avctx)

> >

> >      ret = ff_vaapi_decode_issue(avctx, &pic->pic);

> >      if (ret < 0)

> > -        goto fail;

> > +        return ret;

> >

> >      return 0;

> >  fail:

> 

> I believe this should match the behavior in vaapi_h264/mpeg4/.../vc1.c, and

> remove the redundant  ff_vaapi_decode_cancel in vaapi_hevc_end_frame().

> 

> --Linjie


Hello Linjie, there is little different between vaapi_hevc and other vaapi codecs. 
vaapi_hevc has an extra code block to handle slice buffer before ff_vaapi_decode_issue() , and if it's failed to handle, the buffers have to be destroyed separately.
So the calling of ff_vaapi_decode_cancel() here is a must for hevc.
diff mbox

Patch

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 19aabcd..373ffc4 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -271,7 +271,7 @@  static int vaapi_hevc_end_frame(AVCodecContext *avctx)
 
     ret = ff_vaapi_decode_issue(avctx, &pic->pic);
     if (ret < 0)
-        goto fail;
+        return ret;
 
     return 0;
 fail: