From c1185ab40f40a99993acb764c2a0097de20de6be Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 5 Jun 2024 19:18:49 +0300 Subject: [PATCH] Another attempt to prevent crashes when resizing TTY frames * src/dispnew.c (frame_size_change_delayed): Accept frame as argument, and check the 'new_size_p' flag of the frame in addition to 'delayed_size_change'. Callers changed. (window_to_frame_vpos, build_frame_matrix_from_leaf_window): Call 'frame_size_change_delayed' instead of looking at delayed_size_change alone. (Bug#71289) (cherry picked from commit e84057d072eaaa5e395d796a41bb78613844fb7c) --- src/cm.c | 2 +- src/dispextern.h | 2 +- src/dispnew.c | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cm.c b/src/cm.c index c6c64d95a2a..f6101272d69 100644 --- a/src/cm.c +++ b/src/cm.c @@ -113,7 +113,7 @@ cmcheckmagic (struct tty_display_info *tty) { /* If we have an unhandled SIGWINCH, we don't really know what our up-to-date frame dimensions are. */ - if (frame_size_change_delayed ()) + if (frame_size_change_delayed (XFRAME (tty->top_frame))) return; if (curX (tty) == FrameCols (tty)) { diff --git a/src/dispextern.h b/src/dispextern.h index 8207e74a90c..35e1893c83c 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3812,7 +3812,7 @@ extern void gui_update_window_end (struct window *, bool, bool); #endif void do_pending_window_change (bool); void change_frame_size (struct frame *, int, int, bool, bool, bool); -extern bool frame_size_change_delayed (void); +extern bool frame_size_change_delayed (struct frame *); void init_display (void); void syms_of_display (void); extern void spec_glyph_lookup_face (struct window *, GLYPH *); diff --git a/src/dispnew.c b/src/dispnew.c index dfa36a9f54f..a3c5cbbcf00 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -2643,7 +2643,7 @@ build_frame_matrix_from_leaf_window (struct glyph_matrix *frame_matrix, struct w #ifdef GLYPH_DEBUG /* Window row window_y must be a slice of frame row frame_y. */ - eassert (delayed_size_change + eassert (frame_size_change_delayed (XFRAME (w->frame)) || glyph_row_slice_p (window_row, frame_row)); /* If rows are in sync, we don't have to copy glyphs because @@ -3150,7 +3150,7 @@ window_to_frame_vpos (struct window *w, int vpos) eassert (!FRAME_WINDOW_P (XFRAME (w->frame))); eassert (vpos >= 0 && vpos <= w->desired_matrix->nrows); vpos += WINDOW_TOP_EDGE_LINE (w); - eassert (delayed_size_change + eassert (frame_size_change_delayed (XFRAME (w->frame)) || (vpos >= 0 && vpos <= FRAME_TOTAL_LINES (XFRAME (w->frame)))); return vpos; } @@ -6081,13 +6081,13 @@ change_frame_size (struct frame *f, int new_width, int new_height, change_frame_size_1 (f, new_width, new_height, pretend, delay, safe); } -/* Return non-zero if we delayed size-changes and haven't handled them - yet, which means we cannot be sure about the exact dimensions of our - frames. */ +/* Return non-zero if we delayed size-changes of frame F and haven't + handled them yet, which means we cannot be sure about the exact + dimensions of our frames. */ bool -frame_size_change_delayed (void) +frame_size_change_delayed (struct frame *f) { - return delayed_size_change; + return (delayed_size_change || f->new_size_p); } /*********************************************************************** -- 2.39.2