From: Peter Maydell Date: Mon, 20 Dec 2010 21:13:32 +0000 (+0000) Subject: Fix crash if fnext/fprev are given an empty folder list X-Git-Tag: mmh-start~8 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=9530ace10a49d62c80c95914601fa9246099501b;p=mmh Fix crash if fnext/fprev are given an empty folder list Add a check for a NULL pointer, which stops fnext/fprev from segfaulting if given an empty folder list (for example via 'fnext -folders emptyfile'). Signed-off-by: Peter Maydell --- diff --git a/uip/new.c b/uip/new.c index 41d2ebf..254950b 100644 --- a/uip/new.c +++ b/uip/new.c @@ -308,7 +308,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;