emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 660e941235: Avoid crashes in PGTK build due to signal in 'note_


From: Eli Zaretskii
Subject: emacs-29 660e941235: Avoid crashes in PGTK build due to signal in 'note_mouse_highlight'
Date: Sun, 18 Dec 2022 03:32:22 -0500 (EST)

branch: emacs-29
commit 660e941235d0e4e8490d53ad06cdb1e5699634fa
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Avoid crashes in PGTK build due to signal in 'note_mouse_highlight'
    
    * src/xdisp.c (string_buffer_position): Make sure the TO argument
    of 'string_buffer_position_lim' is always inside [BEGV..ZV].
    Otherwise 'string_buffer_position_lim' might call
    'get-char-property' and friends with invalid position, which will
    just signal an error and do nothing useful.  (Bug#60144)
---
 src/xdisp.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 45da496690..06c8b7730c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -6281,13 +6281,16 @@ static ptrdiff_t
 string_buffer_position (Lisp_Object string, ptrdiff_t around_charpos)
 {
   const int MAX_DISTANCE = 1000;
+  ptrdiff_t forward_limit = min (around_charpos + MAX_DISTANCE, ZV);
   ptrdiff_t found = string_buffer_position_lim (string, around_charpos,
-                                               around_charpos + MAX_DISTANCE,
-                                               false);
+                                               forward_limit, false);
 
   if (!found)
-    found = string_buffer_position_lim (string, around_charpos,
-                                       around_charpos - MAX_DISTANCE, true);
+    {
+      ptrdiff_t backward_limit = max (around_charpos - MAX_DISTANCE, BEGV);
+      found = string_buffer_position_lim (string, around_charpos,
+                                         backward_limit, true);
+    }
   return found;
 }
 



reply via email to

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