[Top][All Lists]

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

master 1f149cb: Prevent hanging in next-single-char-property-change

From: Eli Zaretskii
Subject: master 1f149cb: Prevent hanging in next-single-char-property-change
Date: Sat, 9 May 2020 03:29:20 -0400 (EDT)

branch: master
commit 1f149cb392ac4ed99dd1ce2da01178ff0490e746
Author: Federico Tedin <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Prevent hanging in next-single-char-property-change
    * src/textprop.c (Fnext_single_char_property_change): Clarify in
    the doc string the behavior when LIMIT is past the end of OBJECT.
    Stop the search when position gets to end of buffer, for when LIMIT
    is beyond that.  (Bug#40000)
 src/textprop.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/textprop.c b/src/textprop.c
index 960dba3..0876bad 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -766,14 +766,13 @@ the current buffer), POSITION is a buffer position 
(integer or marker).
 If OBJECT is a string, POSITION is a 0-based index into it.
 In a string, scan runs to the end of the string, unless LIMIT is non-nil.
-In a buffer, if LIMIT is nil or omitted, it runs to (point-max), and the
-value cannot exceed that.
+In a buffer, scan runs to end of buffer, unless LIMIT is non-nil.
 If the optional fourth argument LIMIT is non-nil, don't search
 past position LIMIT; return LIMIT if nothing is found before LIMIT.
+However, if OBJECT is a buffer and LIMIT is beyond the end of the
+buffer, this function returns `point-max', not LIMIT.
-The property values are compared with `eq'.
-If the property is constant all the way to the end of OBJECT, return the
-last valid position in OBJECT.  */)
+The property values are compared with `eq'.  */)
   (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object 
   if (STRINGP (object))
@@ -832,6 +831,9 @@ last valid position in OBJECT.  */)
            value = Fget_char_property (position, prop, object);
            if (!EQ (value, initial_value))
+           if (XFIXNAT (position) >= ZV)
+             break;
       position = unbind_to (count, position);

reply via email to

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