]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_daemon.c: fix Coverity CIDs#13659,#13660 Resource leak
authorMarek Schimara <Marek.Schimara@bull.net>
Fri, 17 Jun 2016 08:38:22 +0000 (10:38 +0200)
committerMarek Schimara <Marek.Schimara@bull.net>
Thu, 23 Jun 2016 14:32:33 +0000 (16:32 +0200)
        CWE-404 / https://cwe.mitre.org/data/definitions/404.html

src/rrd_daemon.c

index 55247c38075984cbdbd7adbd71e25913da1b68b2..70bfdc128d0efb307373fae2ef05769864452aa5 100644 (file)
@@ -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 */