From 636e9fd6a0c6b7801fd5a0d58fd42c93aab7332d Mon Sep 17 00:00:00 2001 From: Junya Takahashi Date: Mon, 12 Apr 2021 10:14:11 +0200 Subject: [PATCH] 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 --- lisp/epa-file.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- 2.39.2