Handle corner case in news_get_extra_fields() where msglist is empty
authorAndrej Kacian <ticho@claws-mail.org>
Wed, 12 Dec 2018 18:43:13 +0000 (19:43 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Wed, 12 Dec 2018 18:43:13 +0000 (19:43 +0100)
This makes the function quit early, instead of requesting
XHDR with bogus ranges from the server.

Closes bug #4133: trying to read message from an NNTP group (with
all expired articles.

src/news.c

index 61120c4..634a050 100644 (file)
@@ -1125,6 +1125,9 @@ static void news_get_extra_fields(NewsSession *session, FolderItem *item, GSList
        cm_return_if_fail(item->folder != NULL);
        cm_return_if_fail(FOLDER_CLASS(item->folder) == &news_class);
 
+       if (msglist == NULL)
+               return;
+
        news_folder_lock(NEWS_FOLDER(item->folder));
 
        hash_table = g_hash_table_new(g_direct_hash, g_direct_equal);
@@ -1139,6 +1142,11 @@ static void news_get_extra_fields(NewsSession *session, FolderItem *item, GSList
                                GINT_TO_POINTER(msginfo->msgnum), msginfo);
        }
 
+       if (first == -1 || last == -1) {
+               g_hash_table_destroy(hash_table);
+               return;
+       }
+
 /* Newsgroups */
        ok = nntp_threaded_xhdr(item->folder, "newsgroups", first, last, &hdrlist);