Commit c4a4d5f72a for ffmpeg
commit c4a4d5f72a7d89de23043415a0a45090c51c502a
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Fri Oct 16 22:21:59 2026 +0200
avcodec/xsubenc: reject subtitles without rectangles
Fixes: null pointer dereference
Fixes: L22GwbO9rtWF
Fixes: AISLE-2026-0150-00413
Null pointer dereference Replicated through API with ASAN
Found-by: Joshua Rogers <joshua.rogers@aisle.com>
Rejecting the subtitle with AVERROR(EINVAL) was suggested in the report.
diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c
index 6f417c5958..9e43213ac2 100644
--- a/libavcodec/xsubenc.c
+++ b/libavcodec/xsubenc.c
@@ -128,8 +128,13 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf,
return AVERROR_BUFFER_TOO_SMALL;
}
+ if (!h->num_rects) {
+ av_log(avctx, AV_LOG_ERROR, "No subtitle rectangle to encode.\n");
+ return AVERROR(EINVAL);
+ }
+
// TODO: support multiple rects
- if (h->num_rects != 1)
+ if (h->num_rects > 1)
av_log(avctx, AV_LOG_WARNING, "Only single rects supported (%d in subtitle.)\n", h->num_rects);
// TODO: render text-based subtitles into bitmaps