Memory Leak in FreeAltScreen

"Daniel De Graaf" <[email protected]> Sun, 26 Mar 2006 20:10:26 -0600
Newsgroups gmane.comp.gnu.screen
Message-ID <[email protected]>
In FreeAltScreen, the w_alt_mlines and w_alt_hlines entries are not
freed before setting them to zero. This causes a memory leak every
time a screen is switched, which can be demonstrated by the shell
script "for a in `seq 1 1000`; do echo test|less -E;done".

- Daniel De Graaf

--- resize.c.orig	2003-09-08 09:26:31.000000000 -0500
+++ resize.c	2006-03-26 13:16:26.000000000 -0600
@@ -1045,8 +1045,10 @@

   if (p->w_alt_mlines)
     for (i = 0; i < p->w_alt_height; i++)
       FreeMline(p->w_alt_mlines + i);
+  free(p->w_alt_mlines);
+  free(p->w_alt_hlines);
   p->w_alt_mlines = 0;
   p->w_alt_width = 0;
   p->w_alt_height = 0;
   p->w_alt_x = 0;