Avoid rare segfaults in 'check_matrix_pointers'
authorEli Zaretskii <eliz@gnu.org>
Sun, 23 Mar 2025 09:30:17 +0000 (11:30 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 23 Mar 2025 19:34:17 +0000 (20:34 +0100)
* src/dispnew.c (check_window_matrix_pointers): No-op if the
window's frame not ready yet.  (Bug#77200)

(cherry picked from commit e20e8538610ed8b78e0b9f9cc3121c1102a8aaf0)

src/dispnew.c

index e7842bfd501a14395c4def4c154b28da26af6175..7a4b7f394eabfd321411d5474d6a408b9f4280f0 100644 (file)
@@ -3110,18 +3110,22 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
 static void
 check_window_matrix_pointers (struct window *w)
 {
-  while (w)
+  struct frame *f = XFRAME (w->frame);
+
+  if (f->after_make_frame)
     {
-      if (WINDOWP (w->contents))
-       check_window_matrix_pointers (XWINDOW (w->contents));
-      else
+      while (w)
        {
-         struct frame *f = XFRAME (w->frame);
-         check_matrix_pointers (w->desired_matrix, f->desired_matrix);
-         check_matrix_pointers (w->current_matrix, f->current_matrix);
-       }
+         if (WINDOWP (w->contents))
+           check_window_matrix_pointers (XWINDOW (w->contents));
+         else
+           {
+             check_matrix_pointers (w->desired_matrix, f->desired_matrix);
+             check_matrix_pointers (w->current_matrix, f->current_matrix);
+           }
 
-      w = NILP (w->next) ? 0 : XWINDOW (w->next);
+         w = NILP (w->next) ? 0 : XWINDOW (w->next);
+       }
     }
 }