aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2025-02-06 05:38:32 +0100
committerDmitrii Ovchinnikov <ovchinnikov.dmitrii@gmail.com>2025-02-07 13:30:01 +0100
commitf00a08c0cef2875ec746f965ec5f2ebfb8adbe45 (patch)
tree3314d00035aae2524159e81b683b698c08af4d0b
parentc85a748979db507d619ac10d74832d3e33635942 (diff)
downloadffmpeg-f00a08c0cef2875ec746f965ec5f2ebfb8adbe45.tar.gz
avutil/hwcontext_amf: fix crash on uninit after init failed
amf_device_create() calls amf_device_uninit() on errors, but if things were not initialized it will null deref amf_ctx->factory. Fixes: https://github.com/mpv-player/mpv/issues/15814 Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
-rw-r--r--libavutil/hwcontext_amf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavutil/hwcontext_amf.c b/libavutil/hwcontext_amf.c
index 8e0ce1927e..5ba2ec5b07 100644
--- a/libavutil/hwcontext_amf.c
+++ b/libavutil/hwcontext_amf.c
@@ -339,7 +339,7 @@ static int amf_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
static void amf_device_uninit(AVHWDeviceContext *device_ctx)
{
AVAMFDeviceContext *amf_ctx = device_ctx->hwctx;
- AMF_RESULT res;
+ AMF_RESULT res = AMF_NOT_INITIALIZED;
AMFTrace *trace;
if (amf_ctx->context) {
@@ -348,7 +348,9 @@ static void amf_device_uninit(AVHWDeviceContext *device_ctx)
amf_ctx->context = NULL;
}
- res = amf_ctx->factory->pVtbl->GetTrace(amf_ctx->factory, &trace);
+ if (amf_ctx->factory)
+ res = amf_ctx->factory->pVtbl->GetTrace(amf_ctx->factory, &trace);
+
if (res == AMF_OK) {
trace->pVtbl->UnregisterWriter(trace, FFMPEG_AMF_WRITER_ID);
}