From 610ff2db85d8070d5d2ad664bf906b437fc70a31 Mon Sep 17 00:00:00 2001 From: Marek Schimara Date: Fri, 17 Jun 2016 10:38:22 +0200 Subject: [PATCH] src/rrd_daemon.c: fix Coverity CIDs#13659,#13660 Resource leak CWE-404 / https://cwe.mitre.org/data/definitions/404.html --- src/rrd_daemon.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 55247c38..70bfdc12 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -523,12 +523,16 @@ static int check_pidfile(void) if (pid_fd < 0) return pid_fd; - if (read(pid_fd, pid_str, sizeof(pid_str)) <= 0) + if (read(pid_fd, pid_str, sizeof(pid_str)) <= 0) { + close(pid_fd); return -1; + } pid = atoi(pid_str); - if (pid <= 0) + if (pid <= 0) { + close(pid_fd); return -1; + } /* another running process that we can signal COULD be * a competing rrdcached */ @@ -3892,6 +3896,7 @@ static int daemonize (void) /* {{{ */ /*FALLTHRU*/ error: remove_pidfile(); + close(pid_fd); return -1; } /* }}} int daemonize */ -- 2.47.2