[FFmpeg-cvslog] hwcontext_vaapi: avoid fd leak in vaapi_device_derive
Haihao Xiang
git at videolan.org
Mon Jul 27 17:46:04 EEST 2020
ffmpeg | branch: master | Haihao Xiang <haihao.xiang at intel.com> | Fri Jul 24 15:29:03 2020 +0800| [d951eea6fd7d62acff70640db002997db01315fb] | committer: Mark Thompson
hwcontext_vaapi: avoid fd leak in vaapi_device_derive
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d951eea6fd7d62acff70640db002997db01315fb
---
libavutil/hwcontext_vaapi.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index b31cf95850..c1893f239d 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1678,8 +1678,13 @@ static int vaapi_device_derive(AVHWDeviceContext *ctx,
#endif
priv = av_mallocz(sizeof(*priv));
- if (!priv)
+ if (!priv) {
+ if (fd != src_hwctx->fd) {
+ // The fd was opened in this function.
+ close(fd);
+ }
return AVERROR(ENOMEM);
+ }
if (fd == src_hwctx->fd) {
// The fd is inherited from the source context and we are holding
More information about the ffmpeg-cvslog
mailing list