aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2020-07-24 15:29:03 +0800
committerMark Thompson <sw@jkqxz.net>2020-07-27 15:41:32 +0100
commitd951eea6fd7d62acff70640db002997db01315fb (patch)
treee82352f282647aa286c9e00336c7412309e0c4c2
parent9faae05ddf27369838fbd500468484af31f1219c (diff)
downloadffmpeg-d951eea6fd7d62acff70640db002997db01315fb.tar.gz
hwcontext_vaapi: avoid fd leak in vaapi_device_derive
-rw-r--r--libavutil/hwcontext_vaapi.c7
1 files changed, 6 insertions, 1 deletions
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