From: Wilfried Göesgens Date: Wed, 9 Jul 2008 23:08:05 +0000 (+0000) Subject: * catch some more error conditions, double frees... X-Git-Tag: v7.86~2114 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=e98baf58a3e63a60f6d89cc007e7849f175912cf * catch some more error conditions, double frees... --- diff --git a/webcit/iconbar.c b/webcit/iconbar.c index fe9699816..9448e66b9 100644 --- a/webcit/iconbar.c +++ b/webcit/iconbar.c @@ -27,7 +27,7 @@ void do_selected_iconbar(void) { void DontDeleteThis(void *Data){}; -#define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a), b) +#define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b) long IconbarIsENABLED(const char *key, size_t keylen, long defval) { @@ -42,14 +42,14 @@ long IconbarIsENABLED(const char *key, size_t keylen, long defval) static char nbuf[32]; inline const char *PrintInt(void *Prefstr) { - snprintf(nbuf, sizeof(nbuf), "%ld", Prefstr); + snprintf(nbuf, sizeof(nbuf), "%ld", (long)Prefstr); return nbuf; } void LoadIconSettings(void) { struct wcsession *WCC = WC; - StrBuf *iconbar; + StrBuf *iconbar = NULL; StrBuf *buf = NewStrBuf();; StrBuf *key = NewStrBuf(); long val; diff --git a/webcit/messages.c b/webcit/messages.c index 6e3246a3e..81f2da586 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -2458,7 +2458,7 @@ void readloop(char *oper) } if (WCC->is_mobile) { maxmsgs = 20; - sortby = "rdate"; + StrBufPrintf(sortby, "rdate"); } /** diff --git a/webcit/preferences.c b/webcit/preferences.c index 2d803e9f7..6c59ed24d 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -146,6 +146,8 @@ void save_preferences(void) { { size_t nchars; Buf = (StrBuf*) Value; + if (Buf == NULL) + continue; nchars = StrLength(Buf); if (nchars > 80){ int n = 0; diff --git a/webcit/roomops.c b/webcit/roomops.c index 4ade41486..6a96bf819 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -3539,24 +3539,28 @@ void list_all_rooms_by_floor(const char *viewpref) { */ void knrooms(void) { - StrBuf *ListView; + StrBuf *ListView = NULL; output_headers(1, 1, 2, 0, 0, 0); /** Determine whether the user is trying to change views */ - if (bstr("view") != NULL) { - if (havebstr("view")) { - set_preference("roomlistview", NewStrBufPlain(bstr("view"), -1), 1); - } + if (havebstr("view")) { + ListView = NewStrBufPlain(bstr("view"), -1); + set_preference("roomlistview", ListView, 1); } - + /** Sanitize the input so its safe */ if(!get_preference("roomlistview", &ListView) || - ((strcasecmp(ChrPtr(ListView), "folders")) - && (strcasecmp(ChrPtr(ListView), "table")))) { - if (ListView == NULL) - ListView = NewStrBuf(); - StrBufPrintf(ListView, "%s", "rooms"); - set_preference("roomlistview", ListView, 0); + ((strcasecmp(ChrPtr(ListView), "folders") != 0) && + (strcasecmp(ChrPtr(ListView), "table") != 0))) + { + if (ListView == NULL) { + ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1); + set_preference("roomlistview", ListView, 0); + } + else { + StrBufPrintf(ListView, "rooms"); + save_preferences(); + } } /** title bar */