From f520008744b1eb71accded4108888d1f2055402e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 9 Oct 2024 16:21:08 +0300 Subject: Avoid segfaults in Rmail-MIME Rmail-MIME decodes text of email, including removal of CR characters, but that can segfault if the text of some MIME part is empty. * src/coding.c (decode_coding_raw_text): * lisp/mail/rmailmm.el (rmail-mime-insert-decoded-text): Don't attempt to decode empty text region. --- src/coding.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index b21ed360578..5591b7fed45 100644 --- a/src/coding.c +++ b/src/coding.c @@ -5270,7 +5270,9 @@ decode_coding_raw_text (struct coding_system *coding) coding->chars_at_source = 1; coding->consumed_char = coding->src_chars; coding->consumed = coding->src_bytes; - if (eol_dos && coding->source[coding->src_bytes - 1] == '\r') + if (eol_dos + && coding->src_bytes > 0 /* empty source text? */ + && coding->source[coding->src_bytes - 1] == '\r') { coding->consumed_char--; coding->consumed--; -- cgit v1.2.1