From 91578639c613de830efd9238491e20a9ceab2957 Mon Sep 17 00:00:00 2001 From: shivanayak Date: Mon, 9 Mar 2026 23:45:38 +0530 Subject: [PATCH] daemon: fix fd leak in do_inotify_files on error paths (#319) When popen or do_inotify_read fails, the file descriptor created by mkstemp is never closed before returning. Add close(fd) to both error paths to prevent file descriptor leaks. Co-authored-by: Claude --- daemon/inotify.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/daemon/inotify.c b/daemon/inotify.c index f1335e8eb..207bed5eb 100644 --- a/daemon/inotify.c +++ b/daemon/inotify.c @@ -331,6 +331,7 @@ do_inotify_files (void) pp = popen (cmd, "w"); if (pp == NULL) { reply_with_perror ("sort"); + close (fd); unlink (tempfile); return NULL; } @@ -339,6 +340,7 @@ do_inotify_files (void) events = do_inotify_read (); if (events == NULL) { pclose (pp); + close (fd); unlink (tempfile); return NULL; }