[FFmpeg-devel] [PATCH] avcodec/decode: use avcodec_get_hw_config()

Kacper Michajłow kasper93 at gmail.com
Sun Jun 2 04:38:18 EEST 2024


Fixes libavcodec/decode.c:1035:61: runtime error: member access within
null pointer of type 'const struct AVCodecHWConfigInternal'.

This can happen when hwaccel fails to initialize and hw_configs[i] is
NULL.

Signed-off-by: Kacper Michajłow <kasper93 at gmail.com>
---
 libavcodec/decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 791940648d..ced4ff3421 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1032,7 +1032,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 &
-- 
2.43.0



More information about the ffmpeg-devel mailing list