restorecond: close the PID file if writing to it failed
write_pid_file() leaks a file descriptor to /var/run/restorecond.pid if
it fails to write the PID to it. Close the file before returning.
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
diff --git a/restorecond/restorecond.c b/restorecond/restorecond.c
index 6fbbd35..e1d26cb 100644
--- a/restorecond/restorecond.c
+++ b/restorecond/restorecond.c
@@ -105,6 +105,7 @@
}
if (write(pidfd, val, (unsigned int)len) != len) {
syslog(LOG_ERR, "Unable to write to pidfile (%s)", strerror(errno));
+ close(pidfd);
return 1;
}
close(pidfd);