From 2711b370db589080300128fc634d71e897435ec9 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 19 Jul 2007 16:25:00 +0000 Subject: fixed another memory leak on HUPing and on exiting rsyslogd again thanks to varmojfekoj for the patch --- ChangeLog | 2 ++ syslogd.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index cde1323b..74d6f43c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ Version 1.17.1 (RGer), 2007-07-?? - minor code cleanup - thanks to Peter Vrabec for the patch - fixed minimal memory leak on HUP (caused by templates) thanks to varmojfekoj for the patch +- fixed another memory leak on HUPin and on exiting rsyslogd + again thanks to varmojfekoj for the patch - code cleanup (removed compiler warnings) - fixed portability bug in configure.ac - thanks to Bartosz Kuźma for patch - moved msg object into its own file set diff --git a/syslogd.c b/syslogd.c index 61388841..7b23a3da 100644 --- a/syslogd.c +++ b/syslogd.c @@ -6194,7 +6194,7 @@ static void doDie(int sig) */ static void die(int sig) { - register selector_t *f; + register selector_t *f, *fPrev; char buf[256]; int i; int was_initialized = Initialized; @@ -6228,7 +6228,7 @@ static void die(int sig) /* Free ressources and close MySQL connections */ - for (f = Files; f != NULL ; f = f->f_next) { + for (f = Files; f != NULL ;) { /* free iovec if it was allocated */ if(f->f_iov != NULL) { if(f->f_bMustBeFreed != NULL) { @@ -6244,6 +6244,9 @@ static void die(int sig) if (f->f_type == F_MYSQL) closeMySQL(f); #endif + fPrev = f; + f = f->f_next; + free(fPrev); } /* now clean up the listener part */ @@ -6273,7 +6276,6 @@ static void die(int sig) * easier. */ tplDeleteAll(); - free(Files); if(consfile.f_iov != NULL) free(consfile.f_iov); if(consfile.f_bMustBeFreed != NULL) @@ -6907,6 +6909,9 @@ static void init() pthread_mutex_destroy(&f->f_un.f_forw.mtxTCPSend); } # endif + if(f->f_pMsg != NULL) + MsgDestruct(f->f_pMsg); + /* done with this entry, we now need to delete itself */ fPrev = f; f = f->f_next; -- cgit v1.2.3