From 9685774e38dc6f5670c8e57dc9f49335f4f738b6 Mon Sep 17 00:00:00 2001 From: "Charles A. Roelli" Date: Mon, 18 Dec 2017 20:51:30 +0100 Subject: [PATCH] Fix infinite loop in vc-dir-mark-unmark * lisp/vc/vc-dir.el (vc-dir-mark-unmark): Prevent from getting stuck on the same line in an infinite loop. (Bug#24017) --- lisp/vc/vc-dir.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 41c44e2c24a..52c7d3e658b 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -554,11 +554,15 @@ If a prefix argument is given, move by that many lines." (defun vc-dir-mark-unmark (mark-unmark-function) (if (use-region-p) - (let (;; (firstl (line-number-at-pos (region-beginning))) + (let ((processed-line nil) (lastl (line-number-at-pos (region-end)))) (save-excursion (goto-char (region-beginning)) - (while (<= (line-number-at-pos) lastl) + (while (and (<= (line-number-at-pos) lastl) + ;; We make sure to not get stuck processing the + ;; same line in an infinite loop. + (not (eq processed-line (line-number-at-pos)))) + (setq processed-line (line-number-at-pos)) (condition-case nil (funcall mark-unmark-function) ;; `vc-dir-mark-file' signals an error if we try marking -- 2.39.2