Subject: bug#58028: 29.0.50; Ensures no leakage of glyph_matrix

From: Manuel Giraud <[email-masked]>
Date: Sat, 24 Sep 2022 12:29:17 +0200

Eli Zaretskii <[email-masked]> writes:

[...]

> Yes, that's what I meant.
>
> So we can install your change with the above assertion added, and then
> wait for the assertion to trigger and investigate the case(s) where it
> triggers to see whether we are missing something.

Ok.  So, as Po suggested, I did a "make check" with and without the new
attached patch and get the same following summary result:

SUMMARY OF TEST RESULTS
-----------------------
Files examined: 450
Ran 6454 tests, 6340 results as expected, 18 unexpected, 96 skipped
1 files did not contain any tests:
  src/emacs-module-tests.log
10 files contained unexpected results:
  src/process-tests.log
  lisp/wdired-tests.log
  lisp/vc/vc-tests.log
  lisp/play/fortune-tests.log
  lisp/net/nsm-tests.log
  lisp/gnus/gnus-icalendar-tests.log
  lisp/epg-tests.log
  lisp/calendar/icalendar-tests.log
  lisp/bookmark-tests.log
  lisp/net/tramp-tests.log

Thanks.
>From ecd618cded21b2ad9d02c991e8f63b5137fe7b41 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Fri, 23 Sep 2022 17:14:44 +0200
Subject: [PATCH] Ensures no leakage of glyph_matrix

; * src/dispnew.c (allocate_matrices_for_window_redisplay): Ensures no
leakage of glyph_matrix.
---
 src/dispnew.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/dispnew.c b/src/dispnew.c
index b786f0f1ba..9e4b43087e 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1807,11 +1807,13 @@ allocate_matrices_for_window_redisplay (struct window *w)
 	  struct dim dim;
 
 	  /* If matrices are not yet allocated, allocate them now.  */
+	  eassert ((w->desired_matrix == NULL)
+		   && (w->current_matrix != NULL));
 	  if (w->desired_matrix == NULL)
-	    {
-	      w->desired_matrix = new_glyph_matrix (NULL);
-	      w->current_matrix = new_glyph_matrix (NULL);
-	    }
+	    w->desired_matrix = new_glyph_matrix (NULL);
+
+	  if (w->current_matrix == NULL)
+	    w->current_matrix = new_glyph_matrix (NULL);
 
 	  dim.width = required_matrix_width (w);
 	  dim.height = required_matrix_height (w);
-- 
2.37.3

-- 
Manuel Giraud