we need to free the array _after_ releasing the array entries
[citadel.git] / citadel / modules / imap / imap_list.c
index 49c19a6666407eae59206ed5af5e7a28165b3ed5..5640ec5db854d8e09af2a545a0882f45388711bd 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2009 by Art Cancro and others.
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  This program is open source software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
@@ -189,13 +189,13 @@ void imap_listroom(struct ctdlroom *qrbuf, void *data)
  */
 void imap_list(int num_parms, ConstStr *Params)
 {
-       citimap *Imap = IMAP;
+       struct CitContext *CCC = CC;
+       citimap *Imap = CCCIMAP;
        int i, j, paren_nest;
        ImapRoomListFilter ImapFilter;
        int selection_left = (-1);
        int selection_right = (-1);
        int return_left = (-1);
-       int return_right = (-1);
        int root_pos = 2;
        int patterns_left = 3;
        int patterns_right = 3;
@@ -377,7 +377,7 @@ void imap_list(int num_parms, ConstStr *Params)
                                          &Params[i], 
                                          1);
 
-                       syslog(LOG_DEBUG, "evaluating <%s>", Params[i].Key);
+                       IMAP_syslog(LOG_DEBUG, "evaluating <%s>", Params[i].Key);
 
                        if (!strcasecmp(Params[i].Key, "SUBSCRIBED")) {
                                ImapFilter.return_subscribed = 1;
@@ -388,7 +388,6 @@ void imap_list(int num_parms, ConstStr *Params)
                        }
 
                        if (paren_nest == 0) {
-                               return_right = i;       /* found end of patterns */
                                i = num_parms + 1;      /* break out of the loop */
                        }
                }
@@ -421,9 +420,8 @@ void imap_list(int num_parms, ConstStr *Params)
         */
        for (i=0; i<ImapFilter.num_patterns; ++i) {
                FreeStrBuf(&ImapFilter.patterns[i]);
-               free(ImapFilter.patterns);
-
        }
+       free(ImapFilter.patterns);
 
        IReplyPrintf("OK %s completed", ImapFilter.verb);
 }