screen-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [screen-devel] Memory Leak in FreeAltScreen


From: Juergen Weigert
Subject: Re: [screen-devel] Memory Leak in FreeAltScreen
Date: Mon, 27 Mar 2006 12:43:57 +0200

On Mar 27, 06 05:41:04 +0100, Bill Pursell wrote:
> Daniel De Graaf wrote:
> >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;
> >
> >
> 
> Freeing a memory address and then assigning to it is a bad idea.  Simply 
> freeing it is adequate.

why bad idea? I prefer to die in the NULL-Pointer access, 
than go amok in memory that I do no longer own.

        cheers,
                Jw.

-- 
 o \  Juergen Weigert  paint it green! __/ _=======.=======_
<V> | address@hidden       wide open suse_/        _---|____________\/
 \  | 0911 74053-508         (tm)__/          (____/            /\
(/) | __________________________/             _/ \_ vim:set sw=2 wm=8




reply via email to

[Prev in Thread] Current Thread [Next in Thread]