PR #22883 opened by Marvin Scholz (ePirat) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22883 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22883.patch
Handle memory allocation errors properly and propagate errors instead of ignoring them. >From e192bb5ad76405813dbdde9a19a8b58600a37add Mon Sep 17 00:00:00 2001 From: Marvin Scholz <[email protected]> Date: Tue, 21 Apr 2026 23:40:07 +0200 Subject: [PATCH 1/2] lavfi: vf_drawtext: check memory allocation Switch to av_calloc and check the allocation. Fix #22867 --- libavfilter/vf_drawtext.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index d2d3bd8f69..2705169245 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1435,8 +1435,12 @@ continue_on_failed: } s->line_count = line_count; - s->lines = av_mallocz(line_count * sizeof(TextLine)); - s->tab_clusters = av_mallocz(s->tab_count * sizeof(uint32_t)); + s->lines = av_calloc(line_count, sizeof(TextLine)); + s->tab_clusters = av_calloc(s->tab_count, sizeof(uint32_t)); + if (!s->lines || !s->tab_clusters) { + ret = AVERROR(ENOMEM); + goto done; + } for (i = 0; i < s->tab_count; ++i) { s->tab_clusters[i] = -1; } -- 2.52.0 >From 2b87125dda9d46cbe5184e8aaedadc20c6f4465b Mon Sep 17 00:00:00 2001 From: Marvin Scholz <[email protected]> Date: Tue, 21 Apr 2026 23:41:05 +0200 Subject: [PATCH 2/2] lavfi: vf_drawtext: properly propagate errors Do not ignore errors from draw_text(). --- libavfilter/vf_drawtext.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 2705169245..586bf28dc5 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1888,7 +1888,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) s->x = bbox->x; s->y = bbox->y - s->fontsize; } - draw_text(ctx, frame); + ret = draw_text(ctx, frame); + if (ret < 0) { + av_frame_free(&frame); + return ret; + } } return ff_filter_frame(outlink, frame); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
