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 <linjie...@intel.com> --- 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(&pic->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(&pic->slice_buffers); + return err; } -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel