* `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,
char *line;
size_t len;
- *first = *cur_node = NULL;
+ *first = *last = *cur_node = NULL;
*maxlen = 0;
b.first = first;
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;