From: Junya Takahashi Date: Mon, 12 Apr 2021 08:14:11 +0000 (+0200) Subject: Fix args-out-of-range error in epa-file-insert-file-contents X-Git-Tag: emacs-28.0.90~2889 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=636e9fd6a0c6b7801fd5a0d58fd42c93aab7332d;p=emacs.git Fix args-out-of-range error in epa-file-insert-file-contents * lisp/epa-file.el (epa-file-insert-file-contents): Don't bug out on a region that's longer than the file (bug#47718). Copyright-paperwork-exempt: yes --- diff --git a/lisp/epa-file.el b/lisp/epa-file.el index e46e3684c8a..33bf5adabe6 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -198,7 +198,9 @@ encryption is used." (mapcar #'car (epg-context-result-for context 'encrypted-to))) (if (or beg end) - (setq string (substring string (or beg 0) end))) + (setq string (substring string + (or beg 0) + (and end (min end (length string)))))) (save-excursion ;; If visiting, bind off buffer-file-name so that ;; file-locking will not ask whether we should