>From bad839ca47ac58bd4967b95f447a596940e832f1 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 17 Jul 2019 07:20:20 -0400 Subject: [PATCH] Handle completely undecoded input in term (Bug#29918) * lisp/term.el (term-emulate-terminal): Avoid errors if the whole decoded string is eight-bit characters. Accumulate at most 4 undecoded bytes. --- lisp/term.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/term.el b/lisp/term.el index cbef68dc0a..2fdd3253ec 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -2900,9 +2900,11 @@ term-emulate-terminal ;; next time. (when (= funny str-length) (let ((partial 0)) - (while (eq (char-charset (aref decoded-substring - (- count 1 partial))) - 'eight-bit) + (while (and (< partial count) + (< partial 4) + (eq (char-charset (aref decoded-substring + (- count 1 partial))) + 'eight-bit)) (cl-incf partial)) (when (> partial 0) (setq term-terminal-undecoded-bytes -- 2.11.0