Commit a3bfdd7318 for ffmpeg
commit a3bfdd7318929fea85872db37aa37f28dddc04d2
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Tue Oct 13 06:39:23 2026 +0200
avcodec/decode: use avcodec_get_hw_config() in avcodec_default_get_format()
This is not a security issue.
Fixes: e5BUoyG1Jo3N
Fixes: swarm-NULL-pointer-dereference-in-hw_configs-iteration-0b77cc
Regression since: 67e81d79cc
NULL pointer member access Replicated through API with UBSAN
Found-by: zhang xingxing <2388969553@qq.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 627ad9420a..96da70fb7e 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1019,7 +1019,7 @@ enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *avctx,
AVHWDeviceContext *device_ctx =
(AVHWDeviceContext*)avctx->hw_device_ctx->data;
for (i = 0;; i++) {
- config = &ffcodec(avctx->codec)->hw_configs[i]->public;
+ config = avcodec_get_hw_config(avctx->codec, i);
if (!config)
break;
if (!(config->methods &