---
 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

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to