From: "김현호(HYUN HO KIM) via ffmpeg-devel" <ffmpeg-devel@ffmpeg.org>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Cc: "김현호(HYUN HO KIM)" <hh3.kim@hanwha.com>
Subject: [FFmpeg-devel] [PATCH] avcodec/qsv: Multiple calls to ff_qsv_init_session_frames() cause handle and memory leaks.
Date: Tue, 28 Oct 2025 12:28:16 +0000
Message-ID: <67afd6cd2472418eb4668f64f9f3a0d3@hanwha.com> (raw)
Within qsvdec.c, ff_qsv_init_session_frames() is typically called twice during decoder initialization. Although qsv_create_mids() may be called if avctx->hw_frames_ctx exists, this procedure causes memory and handle leaks because the existing created resources are merely set to NULL before ff_refstruct_unref() is called.
Signed-off-by: Hyunho Kim <hh3.kim@hanwha.com>
---
libavcodec/qsv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 8a3dc95706..d8ddf85392 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -1133,13 +1133,13 @@ int ff_qsv_init_session_frames(AVCodecContext *avctx, mfxSession *psession,
return ret;
if (!opaque) {
+ /* clean up the exist mids */
+ ff_refstruct_unref(&qsv_frames_ctx->mids);
qsv_frames_ctx->logctx = avctx;
- qsv_frames_ctx->mids = NULL;
qsv_frames_ctx->nb_mids = 0;
/* allocate the memory ids for the external frames */
if (frames_hwctx->nb_surfaces) {
- ff_refstruct_unref(&qsv_frames_ctx->mids);
qsv_frames_ctx->mids = qsv_create_mids(qsv_frames_ctx->hw_frames_ctx);
if (!qsv_frames_ctx->mids)
return AVERROR(ENOMEM);
--
2.48.1.windows.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-10-28 12:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67afd6cd2472418eb4668f64f9f3a0d3@hanwha.com \
--to=ffmpeg-devel@ffmpeg.org \
--cc=hh3.kim@hanwha.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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