util: avoid double close of fd

We could end with a double close if we close the fd loop and flush_fd
fails. That would make us goto fail and there we close the fd once
again. This patch sets the fd to the return value for safe_close: -1
A fd with negative value will be ignored by the next call to
safe_close.

CID#996223
This commit is contained in:
Thomas Hindoe Paaboel Andersen
2014-10-08 23:57:32 +02:00
parent 5ab99e076c
commit 6f53e671aa
Notes: Lennart Poettering 2014-10-27 13:03:00 +01:00
Backport: bugfix

View File

@@ -2074,7 +2074,7 @@ int acquire_terminal(
* ended our handle will be dead. It's important that
* we do this after sleeping, so that we don't enter
* an endless loop. */
safe_close(fd);
fd = safe_close(fd);
}
safe_close(notify);