From da85a87962cad14fb6dee231fe019fadafa1107e Mon Sep 17 00:00:00 2001 From: Junya Takahashi Date: Mon, 12 Apr 2021 13:09:35 +0900 Subject: [PATCH] Fix args-out-of-range error in epa-file-insert-file-contents Fix error below: $ echo -n test > test $ gpg -c test elisp> (epa-file-insert-file-contents "test.gpg" nil 0 5) ;; => Args out of range: "test", 0, 5 --- 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 e46e3684c8..33bf5adabe 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -198,7 +198,9 @@ epa-file-insert-file-contents (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.31.1