aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTong Wu <tong1.wu-at-intel.com@ffmpeg.org>2023-06-19 14:15:07 +0800
committerHaihao Xiang <haihao.xiang@intel.com>2023-06-25 10:01:51 +0800
commit28ed898ac6dcb78dab42913513e85038c069aa33 (patch)
treeffca052489ca2aff79394acd7664b9f8fa69e167
parent13a10fe8925ddc78500107e34799d84dd568a434 (diff)
downloadffmpeg-28ed898ac6dcb78dab42913513e85038c069aa33.tar.gz
avutil/hwcontext_qsv: register free function for device_derive
When qsv device is created by device_derive, the ctx->free function is not registered, causing potential memory leak because of not properly closing the MFX session. Signed-off-by: Tong Wu <tong1.wu@intel.com> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
-rw-r--r--libavutil/hwcontext_qsv.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 4ed4242ddf..b1759a93e1 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -2094,6 +2094,15 @@ static int qsv_device_derive(AVHWDeviceContext *ctx,
AVDictionary *opts, int flags)
{
mfxIMPL impl;
+ QSVDevicePriv *priv;
+
+ priv = av_mallocz(sizeof(*priv));
+ if (!priv)
+ return AVERROR(ENOMEM);
+
+ ctx->user_opaque = priv;
+ ctx->free = qsv_device_free;
+
impl = choose_implementation("hw_any", child_device_ctx->type);
return qsv_device_derive_from_child(ctx, impl,
child_device_ctx, flags);