X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fnew.c;h=99d8528b31519052d880f10b5a44c59085828c78;hb=93f22073ff22b277206b0481c1f8f076aee1656d;hp=81a1afb0cbac3c51f657713bc40d5ad839dc05d3;hpb=7e3a3c499d1637d633d385c1058947c02676e3c5;p=mmh diff --git a/uip/new.c b/uip/new.c index 81a1afb..99d8528 100644 --- a/uip/new.c +++ b/uip/new.c @@ -4,8 +4,6 @@ * -- as fnext, move to next folder with unseen messages * -- as fprev, move to previous folder with unseen messages * -- as unseen, scan all unseen messages - * $Id$ - * * This code is Copyright (c) 2008, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. @@ -220,6 +218,8 @@ crawl_callback(char *folder, void *baton) * `cur' points to the name of the current folder, `folders' points to the * name of a .folder (if NULL, crawl all folders), and `sequences' points to * the array of sequences for which to look. + * + * An empty list is returned as first=last=NULL. */ static void check_folders(struct node **first, struct node **last, @@ -231,7 +231,7 @@ check_folders(struct node **first, struct node **last, char *line; size_t len; - *first = *cur_node = NULL; + *first = *last = *cur_node = NULL; *maxlen = 0; b.first = first; @@ -300,7 +300,7 @@ doit(char *cur, char *folders, char *sequences[]) struct node *first, *cur_node, *node, *last, *prev; size_t folder_len; int count, total = 0; - char *command, *sequences_s; + char *command = NULL, *sequences_s = NULL; if (cur == NULL || cur[0] == '\0') { cur = "inbox"; @@ -310,7 +310,10 @@ doit(char *cur, char *folders, char *sequences[]) folders, sequences); if (run_mode == FNEXT || run_mode == FPREV) { - if (first->n_next == NULL) { + if (first == NULL) { + /* No folders at all... */ + return NULL; + } else if (first->n_next == NULL) { /* We have only one node; any desired messages in it? */ if (first->n_field == NULL) { return NULL;