]> granicus.if.org Git - neomutt/commitdiff
fix Slist usage
authorRichard Russon <rich@flatcap.org>
Thu, 19 Sep 2019 17:35:16 +0000 (18:35 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 21 Sep 2019 17:03:21 +0000 (18:03 +0100)
Some config variables were missing NULL checks for Slist types.

email/tags.c
handler.c

index cf0567421f70c70a53ccfb7eded785a7ea940bdb..f12b4b9d0eae4791cc3e307117d9204cb43d91c5 100644 (file)
@@ -88,8 +88,9 @@ static void driver_tags_add(struct TagList *list, char *new_tag)
     tn->transformed = mutt_str_strdup(new_tag_transformed);
 
   /* filter out hidden tags */
-  if (mutt_list_find(&C_HiddenTags->head, new_tag))
-    tn->hidden = true;
+  if (C_HiddenTags)
+    if (mutt_list_find(&C_HiddenTags->head, new_tag))
+      tn->hidden = true;
 
   STAILQ_INSERT_TAIL(list, tn, entries);
 }
index 3cd571d3f85f720186c80fc43598cbb99f0b2f5a..4632371e970bfcfbd703b7ba5d2a31355e9bc73c 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1132,6 +1132,11 @@ static int multilingual_handler(struct Body *a, struct State *s)
   else
     b = a;
 
+  struct Body *choice = NULL;
+  struct Body *first_part = NULL;
+  struct Body *zxx_part = NULL;
+  struct ListNode *np = NULL;
+
   if (C_PreferredLanguages)
   {
     struct Buffer *langs = mutt_buffer_pool_get();
@@ -1139,46 +1144,41 @@ static int multilingual_handler(struct Body *a, struct State *s)
     mutt_debug(LL_DEBUG2, "RFC8255 >> preferred_languages set in config to '%s'\n",
                mutt_b2s(langs));
     mutt_buffer_pool_release(&langs);
-  }
-
-  struct Body *choice = NULL;
-  struct Body *first_part = NULL;
-  struct Body *zxx_part = NULL;
-  struct ListNode *np = NULL;
 
-  STAILQ_FOREACH(np, &C_PreferredLanguages->head, entries)
-  {
-    while (b)
+    STAILQ_FOREACH(np, &C_PreferredLanguages->head, entries)
     {
-      if (mutt_can_decode(b))
+      while (b)
       {
-        if (!first_part)
-          first_part = b;
+        if (mutt_can_decode(b))
+        {
+          if (!first_part)
+            first_part = b;
 
-        if (b->language && (mutt_str_strcmp("zxx", b->language) == 0))
-          zxx_part = b;
+          if (b->language && (mutt_str_strcmp("zxx", b->language) == 0))
+            zxx_part = b;
 
-        mutt_debug(LL_DEBUG2, "RFC8255 >> comparing configuration preferred_language='%s' to mail part content-language='%s'\n",
-                   np->data, b->language);
-        if (b->language && (mutt_str_strcmp(np->data, b->language) == 0))
-        {
-          mutt_debug(LL_DEBUG2, "RFC8255 >> preferred_language='%s' matches content-language='%s' >> part selected to be displayed\n",
+          mutt_debug(LL_DEBUG2, "RFC8255 >> comparing configuration preferred_language='%s' to mail part content-language='%s'\n",
                      np->data, b->language);
-          choice = b;
-          break;
+          if (b->language && (mutt_str_strcmp(np->data, b->language) == 0))
+          {
+            mutt_debug(LL_DEBUG2, "RFC8255 >> preferred_language='%s' matches content-language='%s' >> part selected to be displayed\n",
+                       np->data, b->language);
+            choice = b;
+            break;
+          }
         }
-      }
 
-      b = b->next;
-    }
+        b = b->next;
+      }
 
-    if (choice)
-      break;
+      if (choice)
+        break;
 
-    if (a->parts)
-      b = a->parts;
-    else
-      b = a;
+      if (a->parts)
+        b = a->parts;
+      else
+        b = a;
+    }
   }
 
   if (choice)