Subject: bug#49770: [PATCH] rmailsum: error when message contains no From header

From: Nick Gasson <[email-masked]>
Date: Thu, 29 Jul 2021 21:24:13 +0800

If you open a mbox file in rmail-mode containing a message without a
"From" header and press "h" to display the summary, the following
error occurs:

  Debugger entered--Lisp error: (wrong-type-argument stringp nil)
    string-match("\n" nil)
    rmail-header-summary()
    rmail-create-summary(1 nil nil 101)
    rmail-create-summary-line(1)
    rmail-get-summary(1)
    rmail-new-summary-1("All" (rmail-summary) nil nil)
    rmail-new-summary("All" (rmail-summary) nil)
    rmail-summary()
    funcall-interactively(rmail-summary)
    call-interactively(rmail-summary nil nil)

* lisp/mail/rmailsum.el (rmail-header-summary): Check if from header
is set before scanning it for newlines.
---
 lisp/mail/rmailsum.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el
index 44cff21b0628..436bc78250cb 100644
--- a/lisp/mail/rmailsum.el
+++ b/lisp/mail/rmailsum.el
@@ -758,7 +758,7 @@ rmail-header-summary
 		    len mch lo newline)
                ;; If there are multiple lines in FROM,
                ;; discard up to the last newline in it.
-               (while (setq newline (string-match "\n" from))
+               (while (and from (setq newline (string-match "\n" from)))
                  (setq from (substring from (1+ newline))))
 	       (if (or (null from)
 		       (string-match
-- 
2.30.2