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

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

So I've tested emacs -Q a bit (compiled with --enable-checking=all) with
the attached patch.  I had no error so far.
>From 332ea1a172568a31f8e2ad0dcd921727d30dad68 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 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/dispnew.c b/src/dispnew.c
index b786f0f1ba..2568ba1086 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1810,9 +1810,12 @@ allocate_matrices_for_window_redisplay (struct window *w)
 	  if (w->desired_matrix == NULL)
 	    {
 	      w->desired_matrix = new_glyph_matrix (NULL);
-	      w->current_matrix = new_glyph_matrix (NULL);
+	      eassert (w->current_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);
 	  adjust_glyph_matrix (w, w->desired_matrix, 0, 0, dim);
-- 
2.37.3

-- 
Manuel Giraud