* [FFmpeg-devel] [PATCH] avcodec/decode: use avcodec_get_hw_config()
@ 2024-06-02 1:38 Kacper Michajłow
2024-07-01 10:16 ` Anton Khirnov
0 siblings, 1 reply; 3+ messages in thread
From: Kacper Michajłow @ 2024-06-02 1:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Kacper Michajłow
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@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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/decode: use avcodec_get_hw_config()
2024-06-02 1:38 [FFmpeg-devel] [PATCH] avcodec/decode: use avcodec_get_hw_config() Kacper Michajłow
@ 2024-07-01 10:16 ` Anton Khirnov
2024-07-08 14:42 ` Kacper Michajlow
0 siblings, 1 reply; 3+ messages in thread
From: Anton Khirnov @ 2024-07-01 10:16 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Kacper Michajłow
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.
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/decode: use avcodec_get_hw_config()
2024-07-01 10:16 ` Anton Khirnov
@ 2024-07-08 14:42 ` Kacper Michajlow
0 siblings, 0 replies; 3+ messages in thread
From: Kacper Michajlow @ 2024-07-08 14:42 UTC (permalink / raw)
To: FFmpeg development discussions and patches, Kacper Michajłow
On Mon, 1 Jul 2024 at 12:16, Anton Khirnov <anton@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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-08 14:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-02 1:38 [FFmpeg-devel] [PATCH] avcodec/decode: use avcodec_get_hw_config() Kacper Michajłow
2024-07-01 10:16 ` Anton Khirnov
2024-07-08 14:42 ` Kacper Michajlow
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git