From: Alexander Barton Date: Tue, 22 May 2012 11:29:31 +0000 (+0200) Subject: Pidfile_Create(): Don't leak file descriptor on error path X-Git-Tag: rel-19.2-rc1~11 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git;a=commitdiff_plain;h=7faa3ed7d6613f23e998604461f543e763278f7e Pidfile_Create(): Don't leak file descriptor on error path Detected by cppcheck: [src/ngircd/ngircd.c:502]: (error) Resource leak: pidfd --- diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c index f28ff05b..8a93bcb0 100644 --- a/src/ngircd/ngircd.c +++ b/src/ngircd/ngircd.c @@ -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; }