bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20498: 25.0.50; PATCH: break potential infinite loop in (line-move-t


From: Dima Kogan
Subject: bug#20498: 25.0.50; PATCH: break potential infinite loop in (line-move-to-column)
Date: Sun, 03 May 2015 12:32:33 -0700

(line-move-to-column) has a loop that can become infinite:

  (while (and ...)
    (goto-char (previous-char-property-change (point) line-beg)))

If (= (point) line-beg) then the (goto-char) does nothing, and the
condition in the while never changes. This patch adds a check to break
out of the while when this happens:

  (while (and ... (/= (point) line-beg))
    (goto-char (previous-char-property-change (point) line-beg)))

I'm seeing this in the wild with ERC and erc-fill-mode disabled. Simply
moving around an ERC buffer can hit this.

>From 4214ce56af49f506729b0240ea1dbb9c588f6215 Mon Sep 17 00:00:00 2001
From: Dima Kogan <address@hidden>
Date: Sun, 3 May 2015 12:31:13 -0700
Subject: [PATCH] * lisp/simple.el (line-move-to-column): break potential
 infinite loop

(line-move-to-column) has a loop that can become infinite:

  (while (and ...)
    (goto-char (previous-char-property-change (point) line-beg)))

If (= (point) line-beg) then the (goto-char) does nothing, and the condition in
the while never changes. This patch adds a check to break out of the while when 
this happens:

  (while (and ... (/= (point) line-beg))
    (goto-char (previous-char-property-change (point) line-beg)))

I'm seeing this in the wild with ERC and erc-fill-mode disabled. Simply moving
around an ERC buffer can hit this.
---
 lisp/simple.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 31efe38..4873ebd 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5962,7 +5962,8 @@ and `current-column' to be able to ignore invisible text."
        ;; but with a more reasonable buffer position.
        (goto-char normal-location)
        (let ((line-beg (line-beginning-position)))
-         (while (and (not (bolp)) (invisible-p (1- (point))))
+         (while (and (not (bolp)) (invisible-p (1- (point)))
+                      (/= (point) line-beg))
            (goto-char (previous-char-property-change (point) line-beg))))))))
 
 (defun move-end-of-line (arg)
-- 
2.1.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]