Module Name:    src
Committed By:   christos
Date:           Tue Dec 14 21:12:03 UTC 2021

Modified Files:
        src/usr.bin/mail: thread.c

Log Message:
Avoid NULL deref if there is no current thread. From RVP.
Prints "No applicable message"


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/mail/thread.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mail/thread.c
diff -u src/usr.bin/mail/thread.c:1.11 src/usr.bin/mail/thread.c:1.12
--- src/usr.bin/mail/thread.c:1.11	Fri Sep 10 17:52:18 2021
+++ src/usr.bin/mail/thread.c	Tue Dec 14 16:12:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: thread.c,v 1.11 2021/09/10 21:52:18 rillig Exp $	*/
+/*	$NetBSD: thread.c,v 1.12 2021/12/14 21:12:03 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef __lint__
-__RCSID("$NetBSD: thread.c,v 1.11 2021/09/10 21:52:18 rillig Exp $");
+__RCSID("$NetBSD: thread.c,v 1.12 2021/12/14 21:12:03 christos Exp $");
 #endif /* not __lint__ */
 
 #include <assert.h>
@@ -595,6 +595,9 @@ first_visible_message(struct message *mp
 	if (mp == NULL)
 		mp = current_thread.t_head;
 
+	if (mp == NULL)
+		return NULL;
+
 	oldmp = mp;
 	if ((S_IS_RESTRICT(state) && is_tagged(mp)) || mp->m_flag & MDELETED)
 		mp = next_message(mp);

Reply via email to