Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avcodec/qsv: Multiple calls to qsv_decode_init_context() cause memory leaks.
@ 2025-10-28 12:28 김현호(HYUN HO KIM) via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: 김현호(HYUN HO KIM) via ffmpeg-devel @ 2025-10-28 12:28 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: 김현호(HYUN HO KIM)

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-10-28 12:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-28 12:28 [FFmpeg-devel] [PATCH] avcodec/qsv: Multiple calls to qsv_decode_init_context() cause memory leaks 김현호(HYUN HO KIM) via ffmpeg-devel

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