[PR] avutil/tests/hwcontext_cuda: stop leaking frames contexts (PR #24175)

Zhao Zhili via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <[email protected]>
PR #24175 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24175
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24175.patch

# Summary of changes

av_hwframe_get_buffer() requires an empty frame and attaches the
frames context reference itself. The test pre-set
frame->hw_frames_ctx, so the plain assignment in
av_hwframe_get_buffer() overwrote the field without unref-ing the
pre-set reference.

<!--
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 b867253653e7ceea5d44ec6b36b91ed5c8832bed Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Mon, 17 Aug 2026 08:52:28 +0800
Subject: [PATCH] avutil/tests/hwcontext_cuda: stop leaking frames contexts

av_hwframe_get_buffer() requires an empty frame and attaches the
frames context reference itself. The test pre-set
frame->hw_frames_ctx, so the plain assignment in
av_hwframe_get_buffer() overwrote the field without unref-ing the
pre-set reference.
---
 libavutil/tests/hwcontext_cuda.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/libavutil/tests/hwcontext_cuda.c b/libavutil/tests/hwcontext_cuda.c
index e4dec7ec05..3d6e89a9b1 100644
--- a/libavutil/tests/hwcontext_cuda.c
+++ b/libavutil/tests/hwcontext_cuda.c
@@ -80,12 +80,6 @@ static int test_format(AVBufferRef *device_ref, enum AVPixelFormat fmt)
         }
     }
 
-    hw_frame->hw_frames_ctx = av_buffer_ref(frames_ref);
-    if (!hw_frame->hw_frames_ctx) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
-    }
-
     ret = av_hwframe_get_buffer(frames_ref, hw_frame, 0);
     if (ret < 0)
         goto fail;
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.