[icinga-checkins] icinga.org: icinga-core/dev/cgis: fix next_comment pointer in loops in expire and initialization #1979

git at icinga.org git at icinga.org
Tue Jan 3 00:32:17 CET 2012


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

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Tue Nov 15 20:37:33 2011 +0100

fix next_comment pointer in loops in expire and initialization #1979

refs #1979

---

 common/comments.c  |    4 +++-
 xdata/xcddefault.c |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/common/comments.c b/common/comments.c
index 84da9cd..a16ec86 100644
--- a/common/comments.c
+++ b/common/comments.c
@@ -370,9 +370,11 @@ int delete_service_acknowledgement_comments(service *svc) {
 /* checks for an expired comment (and removes it) */
 int check_for_expired_comment(unsigned long comment_id) {
 	comment *temp_comment = NULL;
+	comment *next_comment = NULL;
 
 	/* check all comments */
-	for (temp_comment = comment_list; temp_comment != NULL; temp_comment = temp_comment->next) {
+	for (temp_comment = comment_list; temp_comment != NULL; temp_comment = next_comment) {
+		next_comment = temp_comment->next;
 
 		/* delete the now expired comment */
 		if (temp_comment->comment_id == comment_id && temp_comment->expires == TRUE && temp_comment->expire_time < time(NULL)) {
diff --git a/xdata/xcddefault.c b/xdata/xcddefault.c
index a4e2fea..f69d951 100644
--- a/xdata/xcddefault.c
+++ b/xdata/xcddefault.c
@@ -63,10 +63,12 @@ extern comment *comment_list;
 /* initialize comment data */
 int xcddefault_initialize_comment_data(char *main_config_file) {
 	comment *temp_comment = NULL;
+	comment *next_comment = NULL;
 
 	/* find the new starting index for comment id if its missing*/
 	if (next_comment_id == 0L) {
-		for (temp_comment = comment_list; temp_comment != NULL; temp_comment = temp_comment->next) {
+		for (temp_comment = comment_list; temp_comment != NULL; temp_comment = next_comment) {
+			next_comment = temp_comment->next;
 			if (temp_comment->comment_id >= next_comment_id)
 				next_comment_id = temp_comment->comment_id + 1;
 		}





More information about the icinga-checkins mailing list