PR #24675 opened by Arielfoever URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24675 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24675.patch
The NULL check in av_amf_get_memory_type() was placed after amf_ctx had already been dereferenced, allowing the compiler to optimize it away. Move the check ahead of the read so the AMF_MEMORY_UNKNOWN return remains reachable. Closes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/24599 Fixes: cb2370e546bb4c51b2a0f914f06d4698ae3ab1aa ("avfilter/vf_{vpp,sr,vqe}_amf: Enforce memory type") Co-authored-by: baigeb <[email protected]> Reported-by: baigeb <[email protected]> Signed-off-by: Ariel Yu <[email protected]> # Summary of changes Briefly describe what this PR does and why. <!-- If this PR requires new FATE test samples, attach them to the PR and list their target paths below (relative to the fate-suite root). Attached filenames must match the sample's filename: ```fate-samples # e.g. vorbis/new-sample.ogg ``` --> >From a4f84e824587be96052e7643f2bd40833a5bb91a Mon Sep 17 00:00:00 2001 From: Ariel Yu <[email protected]> Date: Thu, 24 Sep 2026 16:18:41 +0800 Subject: [PATCH] avutil/hwcontext_amf: check amf_ctx before dereferencing it The NULL check in av_amf_get_memory_type() was placed after amf_ctx had already been dereferenced, allowing the compiler to optimize it away. Move the check ahead of the read so the AMF_MEMORY_UNKNOWN return remains reachable. Closes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/24599 Fixes: cb2370e546bb4c51b2a0f914f06d4698ae3ab1aa ("avfilter/vf_{vpp,sr,vqe}_amf: Enforce memory type") Co-authored-by: baigeb <[email protected]> Reported-by: baigeb <[email protected]> Signed-off-by: Ariel Yu <[email protected]> --- libavutil/hwcontext_amf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_amf.c b/libavutil/hwcontext_amf.c index 7889546c9d..f0685c4342 100644 --- a/libavutil/hwcontext_amf.c +++ b/libavutil/hwcontext_amf.c @@ -564,13 +564,16 @@ static void amf_device_uninit(AVHWDeviceContext *device_ctx) enum AMF_MEMORY_TYPE av_amf_get_memory_type(AVAMFDeviceContext *amf_ctx) { - AMFContext *context = amf_ctx->context; + AMFContext *context; AMFContext1 *context1 = NULL; AMFGuid guid1 = IID_AMFContext1(); + /* must precede the read of amf_ctx->context below */ if (!amf_ctx) return AMF_MEMORY_UNKNOWN; + context = amf_ctx->context; // + #ifdef _WIN32 if (AMF_IFACE_CALL(context, GetDX11Device, AMF_DX11_1)) return AMF_MEMORY_DX11; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
