2009-03-27 [colin] 3.7.1cvs27
[claws.git] / src / imap.c
index 3994f5748ea4aaf74db5e10fab02883c7f2f47e4..42a4958f29f95f2e542027e17afa95fecabe2e2b 100644 (file)
@@ -3008,10 +3008,9 @@ static void *imap_get_uncached_messages_thread(void *data)
                                g_slist_free(tags);
                                continue;
                        }
-                       if (tags != NULL) {
-                               g_slist_free(msginfo->tags);
-                               msginfo->tags = NULL;
-                       }
+                       g_slist_free(msginfo->tags);
+                       msginfo->tags = NULL;
+
                        for (cur = tags; cur; cur = cur->next) {
                                gchar *real_tag = imap_modified_utf7_to_utf8(cur->data, TRUE);
                                gint id = 0;
@@ -3021,12 +3020,14 @@ static void *imap_get_uncached_messages_thread(void *data)
                                        got_alien_tags = TRUE;
                                }
                                if (!g_slist_find(msginfo->tags, GINT_TO_POINTER(id))) {
-                                       msginfo->tags = g_slist_append(
+                                       msginfo->tags = g_slist_prepend(
                                                        msginfo->tags,
                                                        GINT_TO_POINTER(id));
                                }
                                g_free(real_tag);
                        }
+                       if (msginfo->tags)
+                               msginfo->tags = g_slist_reverse(msginfo->tags);
                        slist_free_strings(tags);
                        g_slist_free(tags);
                        msginfo->folder = item;
@@ -5777,7 +5778,11 @@ char* imap_utf8_to_modified_utf7(const char *src, gboolean change_spaces)
   unsigned long ucs4 = 0, bitbuf = 0;
 
   /* initialize hex lookup table */
-  char *dst, *res = malloc(2*strlen(src)+1);
+  char *dst, *res;
+
+  if (!src) return NULL;
+
+  res = malloc(2*strlen(src)+1);
   dst = res;
   if(!dst) return NULL;