From 69072fe8d8bc3567ae9426458bc45d432651eed5 Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Tue, 21 Apr 2026 23:40:07 +0200 Subject: [PATCH] lavfi: vf_drawtext: check memory allocation Switch to av_calloc and check the allocation. Fix #22867 --- libavfilter/vf_drawtext.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index d2d3bd8f69..70f2209c8e 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1435,8 +1435,13 @@ 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 ((line_count > 0 && !s->lines) || + (s->tab_count > 0 && !s->tab_clusters)) { + ret = AVERROR(ENOMEM); + goto done; + } for (i = 0; i < s->tab_count; ++i) { s->tab_clusters[i] = -1; }