]> code.citadel.org Git - citadel.git/blobdiff - webcit/roomops.c
* catch some more error conditions, double frees...
[citadel.git] / webcit / roomops.c
index 4ade41486bfe07a7a3586abbc7b09577f2c0b6f6..6a96bf819cd2a1e7c83acbfca22bbd7c2fe66afc 100644 (file)
@@ -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 */