From: Wilfried Göesgens Date: Thu, 31 Jul 2008 21:15:44 +0000 (+0000) Subject: * several memoryleaks X-Git-Tag: v7.86~2060 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=4c9df9f5ffac933f2fe42b3f05de98dcd8adf8f0 * several memoryleaks --- diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 4e10f92b2..4fe4a2dda 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -105,6 +105,7 @@ void do_housekeeping(void) FreeStrBuf(&(sessions_to_kill->UrlFragment1)); FreeStrBuf(&(sessions_to_kill->UrlFragment2)); FreeStrBuf(&(sessions_to_kill->WBuf)); + FreeStrBuf(&(sessions_to_kill->HBuf)); pthread_mutex_unlock(&sessions_to_kill->SessionMutex); sptr = sessions_to_kill->next; @@ -516,7 +517,10 @@ void context_loop(int sock) #endif DeleteHash(&TheSession->urlstrings); DeleteHash(&TheSession->vars); - + FreeStrBuf(&TheSession->WBuf); + FreeStrBuf(&TheSession->HBuf); + + pthread_mutex_unlock(&TheSession->SessionMutex); /* unbind */ /* Free the request buffer */ diff --git a/webcit/gettext.c b/webcit/gettext.c index f044ab6ac..52332f815 100644 --- a/webcit/gettext.c +++ b/webcit/gettext.c @@ -270,6 +270,11 @@ void preset_locale(void) #endif #endif } + +#ifdef HAVE_USELOCALE + locale_t Empty_Locale; +#endif + /** * \brief Create a locale_t for each available language */ @@ -278,8 +283,6 @@ void initialize_locales(void) { char buf[32]; #ifdef HAVE_USELOCALE - locale_t Empty_Locale; - /* create default locale */ Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL); #endif @@ -310,6 +313,17 @@ void initialize_locales(void) { } } +void ShutdownLocale(void) +{ + int i; +#ifdef HAVE_USELOCALE + for (i = 0; i < NUM_LANGS; ++i) { + if (Empty_Locale != wc_locales[i]) + freelocale(wc_locales[i]); + } + freelocale(Empty_Locale); +#endif +} #else /* ENABLE_NLS */ /** \brief dummy for non NLS enabled systems */ diff --git a/webcit/messages.c b/webcit/messages.c index e7f007484..972da57ad 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -2475,7 +2475,8 @@ void readloop(char *oper) sortpref_value = NULL; sortpref_value = sortby; } - + FreeStrBuf(&sortby); + FreeStrBuf(&sortpref_name); SortBy = StrToESort(sortpref_value); /** message board sort */ diff --git a/webcit/notes.c b/webcit/notes.c index 497251d39..0775d9709 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -227,13 +227,16 @@ struct vnote *vnote_new_from_msg(long msgnum) { void write_vnote_to_server(struct vnote *v) { char buf[1024]; + char *pch; serv_puts("ENT0 1|||4"); serv_getln(buf, sizeof buf); if (buf[0] == '4') { serv_puts("Content-type: text/vnote"); serv_puts(""); - serv_puts(vnote_serialize(v)); + pch = vnote_serialize(v); + serv_puts(pch); + free(pch); serv_puts("000"); } } diff --git a/webcit/preferences.c b/webcit/preferences.c index 79ec5d050..11ad3f34f 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -78,6 +78,7 @@ void load_preferences(void) { } FreeStrBuf(&Key); } + FreeStrBuf(&ReadBuf); } } diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 50a7ab8b4..a9ff29458 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -384,6 +384,7 @@ int read_server_binary(StrBuf *Ret, size_t total_len) } } } + FreeStrBuf(&Buf); return StrLength(Ret); } diff --git a/webcit/webcit.c b/webcit/webcit.c index fc3a35f2a..0c0b95845 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -115,8 +115,10 @@ void addurls(char *url, long ulen) aptr = up; while ((aptr < eptr) && (*aptr != '\0') && (*aptr != '=')) aptr++; - if (*aptr != '=') + if (*aptr != '=') { + free(buf); return; + } *aptr = '\0'; aptr++; bptr = aptr; @@ -877,7 +879,6 @@ void output_image() { struct wcsession *WCC = WC; char buf[SIZ]; - char *xferbuf = NULL; off_t bytes; const char *MimeType; @@ -885,7 +886,6 @@ void output_image() serv_getln(buf, sizeof buf); if (buf[0] == '2') { bytes = extract_long(&buf[4], 0); - xferbuf = malloc(bytes + 2); /** Read it from the server */ @@ -1361,7 +1361,7 @@ void session_loop(struct httprequest *req) WCC= WC; if (WCC->WBuf == NULL) - WCC->WBuf = NewStrBuf(); + WC->WBuf = NewStrBufPlain(NULL, 32768); FlushStrBuf(WCC->WBuf); if (WCC->HBuf == NULL) diff --git a/webcit/webcit.h b/webcit/webcit.h index 1e02177b5..19f176b31 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -699,6 +699,7 @@ int ical_ctdl_is_overlap( #ifdef ENABLE_NLS void initialize_locales(void); +void ShutdownLocale(void); #endif extern char *months[]; diff --git a/webcit/webserver.c b/webcit/webserver.c index 56a34eb06..c8c117450 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -242,7 +242,8 @@ int client_read_to(int sock, char *buf, int bytes, int timeout) */ void begin_burst(void) { - WC->WBuf = NewStrBufPlain(NULL, 32768); + if (WC->WBuf == NULL) + WC->WBuf = NewStrBufPlain(NULL, 32768); } @@ -934,6 +935,10 @@ void worker_entry(void) icaltimezone_release_zone_tab (); icalmemory_free_ring (); ShutDownLibCitadel (); + DeleteHash(&HandlerHash); +#ifdef ENABLE_NLS + void ShutdownLocale(void); +#endif lprintf(2, "master shutdown exiting!.\n"); exit(0); }