diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 4ab96dc46a..cf57064355 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -477,7 +477,7 @@ static int load_textfile(AVFilterContext *ctx) return err; } - if (!(tmp = av_realloc(s->text, textbuf_size + 1))) { + if (textbuf_size > SIZE_MAX - 1 || !(tmp = av_realloc(s->text, textbuf_size + 1))) { av_file_unmap(textbuf, textbuf_size); return AVERROR(ENOMEM); }