This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch release/9.1 in repository ffmpeg.
commit 86fe9f0d3de7a46814b844d38100d1ddedb3d52f Author: Michael Niedermayer <[email protected]> AuthorDate: Sun Nov 8 14:09:38 2026 +0100 Commit: Michael Niedermayer <[email protected]> CommitDate: Thu Nov 19 14:55:53 2026 +0100 avfilter/vf_lcevc: keep the output frame while LCEVCdec holds its picture Fixes: use after free Fixes: c6FrmJrjoJee Found during triage of the Fairy review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25134 Use after free Replicated through UnModified FFmpeg with ASAN (cherry picked from commit a6e272469c560d2815f4d99f6687872cd47b6289) Signed-off-by: Michael Niedermayer <[email protected]> --- libavfilter/vf_lcevc.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/libavfilter/vf_lcevc.c b/libavfilter/vf_lcevc.c index c2b6f29926..1aa6b2822e 100644 --- a/libavfilter/vf_lcevc.c +++ b/libavfilter/vf_lcevc.c @@ -29,6 +29,7 @@ typedef struct LCEVCContext { LCEVC_DecoderHandle decoder; + AVFrame *out; int w, h; } LCEVCContext; @@ -209,7 +210,7 @@ static int alloc_enhanced_frame(AVFilterLink *inlink, const AVFrame *out, return 0; } -static int generate_output(AVFilterLink *inlink, AVFrame *out) +static int generate_output(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; @@ -218,23 +219,22 @@ static int generate_output(AVFilterLink *inlink, AVFrame *out) LCEVC_DecodeInformation info; LCEVC_PictureHandle picture; LCEVC_ReturnCode res; + AVFrame *out; res = LCEVC_ReceiveDecoderPicture(lcevc->decoder, &picture, &info); if (res == LCEVC_Again) { int64_t pts; int status; - if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { - av_frame_free(&out); + if (ff_inlink_acknowledge_status(inlink, &status, &pts)) ff_outlink_set_status(outlink, status, pts); - return 0; - } - // this shouldn't be reachable, but instead of asserting, just error out - return AVERROR_BUG; + return 0; } else if (res != LCEVC_Success) { av_log(ctx, AV_LOG_ERROR, "LCEVC_ReceiveDecoderPicture failed\n"); return AVERROR_EXTERNAL; } + out = lcevc->out; + lcevc->out = NULL; av_frame_copy_props(out, (AVFrame *)info.baseUserData); av_frame_remove_side_data(out, AV_FRAME_DATA_LCEVC); @@ -266,25 +266,33 @@ static int generate_output(AVFilterLink *inlink, AVFrame *out) return ff_filter_frame(outlink, out); } -static int receive_frame(AVFilterLink *inlink, AVFrame *out) +static int send_output_picture(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; LCEVCContext *lcevc = ctx->priv; LCEVC_PictureHandle picture; LCEVC_ReturnCode res; int ret; - ret = alloc_enhanced_frame(inlink, out, &picture); - if (ret < 0) + lcevc->out = ff_get_video_buffer(outlink, lcevc->w, lcevc->h); + if (!lcevc->out) + return AVERROR(ENOMEM); + + ret = alloc_enhanced_frame(inlink, lcevc->out, &picture); + if (ret < 0) { + av_frame_free(&lcevc->out); return ret; + } res = LCEVC_SendDecoderPicture(lcevc->decoder, picture); if (res != LCEVC_Success) { av_log(ctx, AV_LOG_ERROR, "LCEVC_SendDecoderPicture failed\n"); + av_frame_free(&lcevc->out); return AVERROR_EXTERNAL; } - return generate_output(inlink, out); + return 0; } static int config_props(AVFilterLink *outlink) @@ -318,7 +326,7 @@ static int activate(AVFilterContext *ctx) LCEVCContext *lcevc = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; - AVFrame *in, *out; + AVFrame *in; int status, ret; FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); @@ -368,15 +376,15 @@ static int activate(AVFilterContext *ctx) lcevc->h = desc.height; } - out = ff_get_video_buffer(outlink, lcevc->w, lcevc->h); - if (!out) - return AVERROR(ENOMEM); + if (!lcevc->out) { + ret = send_output_picture(inlink); + if (ret < 0) + return ret; + } - ret = receive_frame(inlink, out); - if (ret < 0) { - av_frame_free(&out); + ret = generate_output(inlink); + if (ret < 0) return ret; - } flush_bases(ctx); @@ -441,6 +449,7 @@ static av_cold void uninit(AVFilterContext *ctx) LCEVC_FlushDecoder(lcevc->decoder); flush_bases(ctx); LCEVC_DestroyDecoder(lcevc->decoder); + av_frame_free(&lcevc->out); } static const AVFilterPad lcevc_outputs[] = { -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
