From 15e37efd006d34b8129c1c4096679677ec5e8e06 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 1 Apr 2026 20:16:49 +0530 Subject: [PATCH] Fix fd leak on invalid file --- kitty/dnd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kitty/dnd.c b/kitty/dnd.c index 6b62fa13e..386822af6 100644 --- a/kitty/dnd.c +++ b/kitty/dnd.c @@ -522,9 +522,10 @@ drop_send_file_data(Window *w, const char *path) { case EACCES: case EPERM: drop_send_error(w, EPERM); break; default: drop_send_error(w, EIO); break; } + safe_close(fd, __FILE__, __LINE__); return; } - if (!S_ISREG(st.st_mode)) { drop_send_error(w, EINVAL); return; } + if (!S_ISREG(st.st_mode)) { drop_send_error(w, EINVAL); safe_close(fd, __FILE__, __LINE__); return; } size_t data_sz = (size_t)st.st_size; char *data = NULL;