diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el index a5ce5b65cd7..d86e48e6281 100644 --- a/lisp/mail/rmailmm.el +++ b/lisp/mail/rmailmm.el @@ -579,11 +579,13 @@ HEADER is a header component of a MIME-entity object (see (ignore-errors (base64-decode-region pos (point)))) ((string= transfer-encoding "quoted-printable") (quoted-printable-decode-region pos (point)))))) - (decode-coding-region - pos (point) - ;; Use -dos decoding, to remove ^M characters left from base64 or - ;; rogue qp-encoded text. - (coding-system-change-eol-conversion coding-system 1)) + ;; If the text is empty, we don't have anything to decode. + (and (/= pos (point)) + (decode-coding-region + pos (point) + ;; Use -dos decoding, to remove ^M characters left from base64 + ;; or rogue qp-encoded text. + (coding-system-change-eol-conversion coding-system 1))) (if (and (or (not rmail-mime-coding-system) (consp rmail-mime-coding-system)) (not (eq (coding-system-base coding-system) 'us-ascii))) 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--;