[FFmpeg-devel] [PATCH] avcodec/decode: use avcodec_get_hw_config()
Kacper Michajlow
kasper93 at gmail.com
Mon Jul 8 17:42:42 EEST 2024
On Mon, 1 Jul 2024 at 12:16, Anton Khirnov <anton at khirnov.net> wrote:
>
> Quoting Kacper Michajłow (2024-06-02 03:38:18)
> > 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.
>
> How? All this should be runtime-constant.
As we can read in hw_configs description.
> Array of pointers to hardware configurations supported by the codec, or NULL if no hardware supported.
> The array is terminated by a NULL pointer.
It uses for (i = 0;; i++), so it always gets the `public` address.
Since public is the first member of `AVCodecHWConfigInternal`, it
silently works; the offset of `public` is zero, so it remains NULL,
and the check in the next line rejects it. Nevertheless, it is better
to check it correctly as avcodec_get_hw_config() does.
The "fails to initialize" part in the commit message is misleading. I
think I just triggered this part of the code on some fallback path,
but the value of hw_configs[i] is not affected by this.
- Kacper
More information about the ffmpeg-devel
mailing list