From 3e2663f8366ea82f52f47019b63fca243e3f88d9 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. --- lisp/term.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/term.el b/lisp/term.el index cbef68dc0a..9785ce3024 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -2900,11 +2900,12 @@ 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) + (eq (char-charset (aref decoded-substring + (- count 1 partial))) + 'eight-bit)) (cl-incf partial)) - (when (> partial 0) + (when (> count partial 0) (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring -- 2.11.0