[icinga-checkins] icinga.org: icinga-core/dev/core: core: fix various memory leaks in downtime eventhandling on SIGHUP ( Carlos Velasco) #2666

git at icinga.org git at icinga.org
Fri Jun 15 16:50:34 CEST 2012


Module: icinga-core
Branch: dev/core
Commit: 7383da1d25e0a4f428ffd5bb9e9b34a321bff2f9
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=7383da1d25e0a4f428ffd5bb9e9b34a321bff2f9

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Fri Jun 15 14:37:34 2012 +0200

core: fix various memory leaks in downtime eventhandling on SIGHUP (Carlos Velasco) #2666

under various circumstances, the event_data was not cleared correctly
when reloading the core, therefore causing memory leaks.

refs #2666

---

 Changelog         |    1 +
 THANKS            |    1 +
 base/utils.c      |    4 ++++
 common/downtime.c |    5 ++++-
 4 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/Changelog b/Changelog
index 340b678..6a0f5f2 100644
--- a/Changelog
+++ b/Changelog
@@ -8,6 +8,7 @@ Thanks to all contributers, testers and developers. Please read AUTHORS and THAN
 
 FIXES
 * core: use prefix in solaris service definition #2609 - TD/CF
+* core: fix various memory leaks in downtime eventhandling on SIGHUP (Carlos Velasco) #2666 - MF
 
 * classic ui: Fixed status.cgi time out when displaying hostgroups in large environments #2617 - RB
 
diff --git a/THANKS b/THANKS
index 94f9639..b6cf76b 100644
--- a/THANKS
+++ b/THANKS
@@ -315,6 +315,7 @@ in various ways.  If we missed your name, let us know.
 * Esteban Manchado Velazquez
 * Geert Vanderkelen
 * Jan Vejvalka
+* Carlos Velasco
 * Robert August Vincent II
 * Dave Viner
 * Ton Voon
diff --git a/base/utils.c b/base/utils.c
index cd0e301..c7acf0a 100644
--- a/base/utils.c
+++ b/base/utils.c
@@ -4264,6 +4264,8 @@ void free_memory(icinga_macros *mac) {
 	/* free memory for the high priority event list */
 	this_event = event_list_high;
 	while (this_event != NULL) {
+		if (this_event->event_type == EVENT_SCHEDULED_DOWNTIME)
+			my_free(this_event->event_data);
 		next_event = this_event->next;
 		my_free(this_event);
 		this_event = next_event;
@@ -4275,6 +4277,8 @@ void free_memory(icinga_macros *mac) {
 	/* free memory for the low priority event list */
 	this_event = event_list_low;
 	while (this_event != NULL) {
+		if (this_event->event_type == EVENT_SCHEDULED_DOWNTIME)
+			my_free(this_event->event_data);
 		next_event = this_event->next;
 		my_free(this_event);
 		this_event = next_event;
diff --git a/common/downtime.c b/common/downtime.c
index 880a6d8..553c50b 100644
--- a/common/downtime.c
+++ b/common/downtime.c
@@ -203,8 +203,11 @@ int unschedule_downtime(int type, unsigned long downtime_id) {
 		if (((unsigned long)temp_event->event_data) == downtime_id)
 			break;
 	}
-	if (temp_event != NULL)
+	if (temp_event != NULL) {
 		remove_event(temp_event, &event_list_high, &event_list_high_tail);
+		my_free(temp_event->event_data);
+		my_free(temp_event);
+	}
 
 	/* delete downtime entry */
 	if (temp_downtime->type == HOST_DOWNTIME)





More information about the icinga-checkins mailing list