From: Marek Schimara Date: Fri, 17 Jun 2016 08:38:22 +0000 (+0200) Subject: src/rrd_daemon.c: fix Coverity CIDs#13659,#13660 Resource leak X-Git-Tag: v1.7.0~42^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=610ff2db85d8070d5d2ad664bf906b437fc70a31;p=thirdparty%2Frrdtool-1.x.git src/rrd_daemon.c: fix Coverity CIDs#13659,#13660 Resource leak CWE-404 / https://cwe.mitre.org/data/definitions/404.html --- 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 */