From bb69a090a7cad34e21c645c8bcedbdd4ed92db5b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 8 Apr 2026 12:23:16 +0200 Subject: [PATCH] avcodec/tdsc: Check jpeg size Fixes: out of array read Fixes: tdsc_tile_dim_mismatch.avi Found-by: Ante Silovic Signed-off-by: Michael Niedermayer --- libavcodec/tdsc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c index 104a45285d..985ed405fc 100644 --- a/libavcodec/tdsc.c +++ b/libavcodec/tdsc.c @@ -358,7 +358,8 @@ static int tdsc_decode_jpeg_tile(AVCodecContext *avctx, int tile_size, } ret = avcodec_receive_frame(ctx->jpeg_avctx, ctx->jpgframe); - if (ret < 0 || ctx->jpgframe->format != AV_PIX_FMT_YUVJ420P) { + if (ret < 0 || ctx->jpgframe->format != AV_PIX_FMT_YUVJ420P || + w > ctx->jpgframe->width || h > ctx->jpgframe->height) { av_log(avctx, AV_LOG_ERROR, "JPEG decoding error (%d).\n", ret);