From 494d819637ac8aeb02ec10d2d514edb189a71f1b Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 22 Jul 2011 22:25:58 -0400 Subject: [PATCH] Tinkered with the memory pointers in sitemap.c to try to hopefully fix the random crashes we have been having. --- webcit/gettext.c | 6 ++++-- webcit/sitemap.c | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/webcit/gettext.c b/webcit/gettext.c index c4920cea7..30a732588 100644 --- a/webcit/gettext.c +++ b/webcit/gettext.c @@ -469,8 +469,10 @@ SessionNewModule_GETTEXT (wcsession *sess) { #ifdef ENABLE_NLS - if (!sess->Hdr->HR.Static && - (sess->Hdr->HR.browser_language != NULL)) { + if ( (sess != NULL) + && (!sess->Hdr->HR.Static) + && (sess->Hdr->HR.browser_language != NULL) + ) { httplang_to_locale(sess->Hdr->HR.browser_language, sess); } #endif diff --git a/webcit/sitemap.c b/webcit/sitemap.c index 37fe310a8..c79c82441 100644 --- a/webcit/sitemap.c +++ b/webcit/sitemap.c @@ -129,11 +129,11 @@ void sitemap_do_wiki(void) { * Entry point for RSS feed generator */ void sitemap(void) { - HashList *roomlist; - HashPos *it; - long HKlen; - const char *HashKey; - folder *room; + HashList *roomlist = NULL; + HashPos *it = NULL; + long HKlen = 0; + const char *HashKey = NULL; + folder *room = NULL; output_headers(0, 0, 0, 0, 1, 0); hprintf("Content-type: text/xml\r\n"); @@ -149,7 +149,9 @@ void sitemap(void) { wc_printf("\r\n"); roomlist = GetRoomListHashLKRA(NULL, NULL); + if (!roomlist) syslog(LOG_CRIT, "GetRoomListHashLKRA() FAILED!"); it = GetNewHashPos(roomlist, 0); + if (!it) syslog(LOG_CRIT, "GetNewHashPos() FAILED!"); while (GetNextHashPos(roomlist, it, &HKlen, &HashKey, (void *)&room)) { @@ -172,8 +174,7 @@ void sitemap(void) { } DeleteHashPos(&it); - /* No need to DeleteHash(&roomlist) -- it will be freed when the session closes */ - + DeleteHash(&WC->Rooms); /* roomlist is actually a pointer to WC->Rooms */ wc_printf("\r\n"); wDumpContent(0); } -- 2.30.2