Pidfile_Create(): Don't leak file descriptor on error path
authorAlexander Barton <alex@barton.de>
Tue, 22 May 2012 11:29:31 +0000 (13:29 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 22 May 2012 11:31:08 +0000 (13:31 +0200)
Detected by cppcheck:
 [src/ngircd/ngircd.c:502]: (error) Resource leak: pidfd

src/ngircd/ngircd.c

index f28ff05bcfb778065dc99a50e7459472eee8a68f..8a93bcb00839a796b262b890d12b373d662ccf56 100644 (file)
@@ -498,7 +498,8 @@ Pidfile_Create(pid_t pid)
 
        len = snprintf(pidbuf, sizeof pidbuf, "%ld\n", (long)pid);
        if (len < 0 || len >= (int)sizeof pidbuf) {
-               Log( LOG_ERR, "Error converting pid");
+               Log(LOG_ERR, "Error converting pid");
+               close(pidfd);
                return;
        }