Re: Memory Leak in FreeAltScreen

"Daniel De Graaf" <[email protected]> Fri, 28 Apr 2006 17:02:46 -0500
Newsgroups gmane.comp.gnu.screen
Message-ID <[email protected]>
Replacement of my previous patch - the other one accessed
p->w_alt_hlines after freeing it. It also woudn't work if COPY_PASTE
was off.

--- screen-4.0.2/resize.c.old   2003-09-08 09:26:31.000000000 -0500
+++ screen-4.0.2/resize.c       2006-04-28 16:48:11.000000000 -0500
@@ -1044,19 +1044,21 @@
   int i;

   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);
   p->w_alt_mlines = 0;
   p->w_alt_width = 0;
   p->w_alt_height = 0;
   p->w_alt_x = 0;
   p->w_alt_y = 0;
 #ifdef COPY_PASTE
   if (p->w_alt_hlines)
     for (i = 0; i < p->w_alt_histheight; i++)
       FreeMline(p->w_alt_hlines + i);
+  free(p->w_alt_hlines);
   p->w_alt_hlines = 0;
   p->w_alt_histidx = 0;
 #endif
   p->w_alt_histheight = 0;
 }