* fix memleak in preferences
authorWilfried Göesgens <willi@citadel.org>
Mon, 26 Jan 2009 17:43:07 +0000 (17:43 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 26 Jan 2009 17:43:07 +0000 (17:43 +0000)
* fix buffer overruns in vcard presenting logic
* zero WC->this_httphost at the end of a session, as it becomes invalid then.

webcit/preferences.c
webcit/vcard_edit.c
webcit/webcit.c

index 732ee1f593c20624432d7aac2c400039ddd2e34d..a245928dfbdea8141d61c24d962ead7c88207165 100644 (file)
@@ -102,6 +102,7 @@ void GetPrefTypes(HashList *List)
                                PrefType->OnLoad(Setting->Val, Setting->lval);
                }
        }
+       DeleteHashPos(&It);
 }
 
 void ParsePref(HashList **List, StrBuf *ReadBuf)
index f56fd1c09e3f780f819734c6263917c2baa8b600..97ef83fa988c572ba30bf0f002b20c9be5ba3333 100644 (file)
@@ -503,7 +503,8 @@ void display_vcard(StrBuf *Target, const char *vcard_source, char alpha, int ful
        long msgnum) {
        struct vCard *v;
        char *name;
-       char buf[SIZ];
+       StrBuf *Buf;
+       StrBuf *Buf2;
        char this_alpha = 0;
 
        v = vcard_load((char*)vcard_source); ///TODO
@@ -512,9 +513,12 @@ void display_vcard(StrBuf *Target, const char *vcard_source, char alpha, int ful
 
        name = vcard_get_prop(v, "n", 1, 0, 0);
        if (name != NULL) {
-               utf8ify_rfc822_string(name);
-               strcpy(buf, name);
-               this_alpha = buf[0];
+               Buf = NewStrBufPlain(name, -1);
+               Buf2 = NewStrBufPlain(NULL, StrLength(Buf));
+               StrBuf_RFC822_to_Utf8(Buf2, Buf, WC->DefaultCharset, NULL);
+               this_alpha = ChrPtr(Buf)[0];
+               FreeStrBuf(&Buf);
+               FreeStrBuf(&Buf2);
        }
 
        if (storename != NULL) {
index d63afdd64db3ae36b6b1b82acb565c10c2bac02e..eaf4d30b735522bce9a94ece3cf1739dc18bddb2 100644 (file)
@@ -1039,6 +1039,7 @@ SKIP_ALL_THIS_CRAP:
                WCC->upload_length = 0;
        }
        FreeStrBuf(&WCC->trailing_javascript);
+       WCC->http_host = NULL;
 }