[FFmpeg-devel] [PATCH] hwcontext_vaapi: avoid fd leak in vaapi_device_derive
Haihao Xiang
haihao.xiang at intel.com
Fri Jul 24 10:29:03 EEST 2020
---
libavutil/hwcontext_vaapi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index fb9be19647..a4dfaba92c 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1698,8 +1698,12 @@ static int vaapi_device_derive(AVHWDeviceContext *ctx,
#endif
priv = av_mallocz(sizeof(*priv));
- if (!priv)
+ if (!priv) {
+ /* fd is opened in this function */
+ if (fd != src_hwctx->fd)
+ close(fd);
return AVERROR(ENOMEM);
+ }
if (fd == src_hwctx->fd) {
// The fd is inherited from the source context and we are holding
--
2.25.1
More information about the ffmpeg-devel
mailing list