mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user