PR #24898 opened by commodo
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24898
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24898.patch

Frames can keep the m2m context alive after the codec is freed, so
ff_v4l2_context_release() in v4l2_m2m_destroy_context() may log
through a dangling s->avctx.

Signed-off-by: Alexandru Ardelean <[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 1a8f5e4b96ee1ddea444c4e6a3bc4d48643a0fb6 Mon Sep 17 00:00:00 2001
From: Alexandru Ardelean <[email protected]>
Date: Tue, 6 Oct 2026 15:31:16 +0300
Subject: [PATCH] avcodec/v4l2_m2m: do not log through a freed AVCodecContext

Frames can keep the m2m context alive after the codec is freed, so
ff_v4l2_context_release() in v4l2_m2m_destroy_context() may log
through a dangling s->avctx.

Signed-off-by: Alexandru Ardelean <[email protected]>
---
 libavcodec/v4l2_m2m.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
index 07c7500000..7a6ef3a54a 100644
--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -281,6 +281,8 @@ av_cold int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
 
     ff_v4l2_context_release(&s->output);
 
+    s->avctx = NULL;
+
     s->self_ref = NULL;
     av_refstruct_unref(&priv->context);
 
-- 
2.52.0

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

Reply via email to