]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid assertion violations in matrix_row
authorEli Zaretskii <eliz@gnu.org>
Wed, 9 Nov 2022 14:25:02 +0000 (16:25 +0200)
committerEli Zaretskii <eliz@gnu.org>
Wed, 9 Nov 2022 14:25:02 +0000 (16:25 +0200)
* src/xdisp.c (cursor_in_mouse_face_p): Avoid rare assertion
violations when the cursor's VPOS winds up being invalid for the
window.  (Bug#59147)

src/xdisp.c

index 95da704a070eb5657d02b2ab7bdcbd0d607f4ce8..f6a279636a043cef08c27fb8a396cec621aad2b9 100644 (file)
@@ -33564,8 +33564,14 @@ coords_in_mouse_face_p (struct window *w, int hpos, int vpos)
 bool
 cursor_in_mouse_face_p (struct window *w)
 {
-  int hpos = w->phys_cursor.hpos;
   int vpos = w->phys_cursor.vpos;
+
+  /* If the cursor is outside the matrix glyph rows, it cannot be
+     within the mouse face.  */
+  if (!(0 <= vpos && vpos < w->current_matrix->nrows))
+    return false;
+
+  int hpos = w->phys_cursor.hpos;
   struct glyph_row *row = MATRIX_ROW (w->current_matrix, vpos);
 
   /* When the window is hscrolled, cursor hpos can legitimately be out