PR #23864 opened by wassim-devel
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23864
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23864.patch

# Summary of changes

Currently, when `avcodec_get_hw_frames_parameters` is passed a codec without 
hardware acceleration, it tries to dereference `hw_configs` without checking if 
it is NULL

This PR adds a check to return `AVERROR(ENOENT)` in case an incompatible codec 
is passed to `avcodec_get_hw_frames_parameters`

The documentation says: 

> AVERROR(ENOENT): the decoder does not support this functionality. Setup is 
> always manual, or it is a decoder which does not support setting 
> AVCodecContext.hw_frames_ctx at all, or it is a software format. 

So it is understood that `AVERROR(ENOENT)` should be returned in that case


>From e6d9d1a6eb7a7e26ca427bbc84fded14468e3431 Mon Sep 17 00:00:00 2001
From: Wassim Lalaoui <[email protected]>
Date: Tue, 21 Jul 2026 11:37:28 +0200
Subject: [PATCH] libavcodec/decode: fix crash on incompatible codec

---
 libavcodec/decode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index ba6ff8a9fd..ec868199a8 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1128,6 +1128,9 @@ int avcodec_get_hw_frames_parameters(AVCodecContext 
*avctx,
     int i, ret;
     bool clean_priv_data = false;
 
+    if (!ffcodec(avctx->codec)->hw_configs)
+        return AVERROR(ENOENT);
+
     for (i = 0;; i++) {
         hw_config = ffcodec(avctx->codec)->hw_configs[i];
         if (!hw_config)
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to