Re: [FFmpeg-devel] [PATCH V2] avcodec/vaapi:free slice_buffers when decoding failed

2018-09-23 Thread Mark Thompson
On 19/09/18 03:01, Linjie Fu wrote:
> If vaEndPicture failed in ff_vaapi_decode_issue, free
> the pic->slice_buffer.
> 
> Fix the memory leak issue in ticket #7385
> 
> [V2] unit the return paths under the "exit" tag at
> the end of the function.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/vaapi_decode.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)

Tested and applied.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH V2] avcodec/vaapi:free slice_buffers when decoding failed

2018-09-18 Thread Linjie Fu
If vaEndPicture failed in ff_vaapi_decode_issue, free
the pic->slice_buffer.

Fix the memory leak issue in ticket #7385

[V2] unit the return paths under the "exit" tag at
the end of the function.

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_decode.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index d0a6b5817d..3ee9c6be51 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -152,7 +152,7 @@ int ff_vaapi_decode_issue(AVCodecContext *avctx,
 {
 VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data;
 VAStatus vas;
-int err;
+int err = 0;
 
 av_log(avctx, AV_LOG_DEBUG, "Decode to surface %#x.\n",
pic->output_surface);
@@ -200,12 +200,7 @@ int ff_vaapi_decode_issue(AVCodecContext *avctx,
 AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS)
 ff_vaapi_decode_destroy_buffers(avctx, pic);
 
-pic->nb_param_buffers = 0;
-pic->nb_slices= 0;
-pic->slices_allocated = 0;
-av_freep(>slice_buffers);
-
-return 0;
+goto exit;
 
 fail_with_picture:
 vas = vaEndPicture(ctx->hwctx->display, ctx->va_context);
@@ -216,6 +211,12 @@ fail_with_picture:
 fail:
 ff_vaapi_decode_destroy_buffers(avctx, pic);
 fail_at_end:
+exit:
+pic->nb_param_buffers = 0;
+pic->nb_slices= 0;
+pic->slices_allocated = 0;
+av_freep(>slice_buffers);
+
 return err;
 }
 
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel