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 <noreply@anthropic.com>
This commit is contained in:
shivanayak
2026-03-09 23:45:38 +05:30
committed by GitHub
parent ff4467a1a4
commit 91578639c6

View File

@@ -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;
}