From a2c8dddaada3d8b8eda81e93868b219adfc77f5b Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 4 Jul 2016 12:42:22 +0200 Subject: [PATCH] Free pidfile_path atexit() To prevent warnings from tools like Valgrind, or handle issues with RAM leaks on non-MMU systems like uClinux, we must free the memory allocated by pidfile(). Signed-off-by: Joachim Nilsson --- pidfile.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pidfile.c b/pidfile.c index af8b67b..5659011 100644 --- a/pidfile.c +++ b/pidfile.c @@ -122,8 +122,10 @@ pidfile(const char *basename) static void pidfile_cleanup(void) { - - if (pidfile_path != NULL && pidfile_pid == getpid()) + if (pidfile_path != NULL && pidfile_pid == getpid()) { (void) unlink(pidfile_path); + free(pidfile_path); + pidfile_path = NULL; + } } #endif