From 9530ace10a49d62c80c95914601fa9246099501b Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Mon, 20 Dec 2010 21:13:32 +0000 Subject: [PATCH] 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 --- uip/new.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; -- 1.7.10.4