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 qsv_decode_init_context() cause memory leaks.
Date: Tue, 28 Oct 2025 12:28:40 +0000
Message-ID: <b6c49875acd247f6b16907657b5d54e6@hanwha.com> (raw)
Calling qsv_decode_flush() results in qsv_decode_init_context() being called again during the next decoding cycle. If q->pool has already been created, this causes a memory leak because new memory is allocated to q->pool without cleaning up the existing memory through av_buffer_pool_uninit(). If q->pool already exists, we can simply reuse it, avoiding further memory allocation and potential leaks.
Signed-off-by: Hyunho Kim <hh3.kim@hanwha.com>
---
libavcodec/qsvdec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 039ba62484..8a17a52da8 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -412,7 +412,7 @@ static int qsv_decode_init_context(AVCodecContext *avctx, QSVContext *q, mfxVide
q->frame_info = param->mfx.FrameInfo;
- if (!avctx->hw_frames_ctx) {
+ if (!avctx->hw_frames_ctx && !q->pool) {
ret = av_image_get_buffer_size(avctx->pix_fmt, FFALIGN(avctx->coded_width, 128), FFALIGN(avctx->coded_height, 64), 1);
if (ret < 0)
return ret;
--
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=b6c49875acd247f6b16907657b5d54e6@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