* several memoryleaks
authorWilfried Göesgens <willi@citadel.org>
Thu, 31 Jul 2008 21:15:44 +0000 (21:15 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 31 Jul 2008 21:15:44 +0000 (21:15 +0000)
webcit/context_loop.c
webcit/gettext.c
webcit/messages.c
webcit/notes.c
webcit/preferences.c
webcit/serv_func.c
webcit/webcit.c
webcit/webcit.h
webcit/webserver.c

index 4e10f92b230f08f92779ffe1640daf15e617213b..4fe4a2dda75dddaf8b1874df42f954e47aff8cbd 100644 (file)
@@ -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 */
index f044ab6ac9ac9f619f4baeee22797f2ed969c090..52332f8152b64a4db519d1e8403c808749969745 100644 (file)
@@ -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 */
index e7f007484a2fa66e3456c9903dd08c6dddbb6d8d..972da57ad998c99b397daadc1194201b0126160b 100644 (file)
@@ -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 */
index 497251d3997c81e25e910e207b0e8c2aa9b42075..0775d9709d11e083adecdf2f993176beb47d8cd9 100644 (file)
@@ -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");
        }
 }
index 79ec5d0504427041936c2ffa7d5988156a5b27fa..11ad3f34fc753c61496a8ea98589fefeee7fe490 100644 (file)
@@ -78,6 +78,7 @@ void load_preferences(void) {
                                }
                                FreeStrBuf(&Key);
                        }
+                       FreeStrBuf(&ReadBuf);
                }
        }
 
index 50a7ab8b46db6e2a2f1679214721bee48e33df94..a9ff29458403911fba1438fd61841caa65a80bf1 100644 (file)
@@ -384,6 +384,7 @@ int read_server_binary(StrBuf *Ret, size_t total_len)
                    }
                }
        }
+       FreeStrBuf(&Buf);
        return StrLength(Ret);
 }
 
index fc3a35f2a224bfa91fcd57dc48251945516e8f59..0c0b95845a0f9c059fb0d71cf1aa593a7fa68160 100644 (file)
@@ -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)
index 1e02177b5a821915bef29c9689fbba19c1bb2d0f..19f176b312f29d56e68e10816f276d0b47429178 100644 (file)
@@ -699,6 +699,7 @@ int ical_ctdl_is_overlap(
 
 #ifdef ENABLE_NLS
 void initialize_locales(void);
+void ShutdownLocale(void);
 #endif
 
 extern char *months[];
index 56a34eb063d819be8435bedf38d7165f461987c8..c8c117450264d9c1441eccd95d4f0ff93b33a5b5 100644 (file)
@@ -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);
                        }