PR #22937 opened by jiangjie URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22937 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22937.patch
>From d3acb940ece5074b2e307e02c5093ce2d13bd909 Mon Sep 17 00:00:00 2001 From: jiangjie <[email protected]> Date: Mon, 27 Apr 2026 20:13:15 +0800 Subject: [PATCH] libavfilter/vf_amf_common: Free the frame allocated by av_frame_alloc on error. --- libavfilter/vf_amf_common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_amf_common.c b/libavfilter/vf_amf_common.c index 248b224e86..7e16c72e86 100644 --- a/libavfilter/vf_amf_common.c +++ b/libavfilter/vf_amf_common.c @@ -397,8 +397,7 @@ AVFrame *amf_amfsurface_to_avframe(AVFilterContext *avctx, AMFSurface* pSurface) int ret = av_hwframe_get_buffer(ctx->hwframes_out_ref, frame, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Get hw frame failed.\n"); - av_frame_free(&frame); - return NULL; + goto fail; } frame->data[0] = (uint8_t *)pSurface; frame->buf[1] = av_buffer_create((uint8_t *)pSurface, sizeof(AMFSurface), @@ -407,7 +406,7 @@ AVFrame *amf_amfsurface_to_avframe(AVFilterContext *avctx, AMFSurface* pSurface) AV_BUFFER_FLAG_READONLY); } else { // FIXME: add processing of other hw formats av_log(ctx, AV_LOG_ERROR, "Unknown pixel format\n"); - return NULL; + goto fail; } } else { @@ -445,13 +444,16 @@ AVFrame *amf_amfsurface_to_avframe(AVFilterContext *avctx, AMFSurface* pSurface) default: { av_log(avctx, AV_LOG_ERROR, "Unsupported memory type : %d\n", pSurface->pVtbl->GetMemoryType(pSurface)); - return NULL; + goto fail; } } } return frame; +fail: + av_frame_free(&frame); + return NULL; } int amf_avframe_to_amfsurface(AVFilterContext *avctx, const AVFrame *frame, AMFSurface** ppSurface) -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
