From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id AAA14861 for ; Fri, 10 May 1996 00:36:42 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id KAA01529; Thu, 9 May 1996 10:16:21 -0400 (EDT) Resent-Date: Thu, 9 May 1996 10:16:21 -0400 (EDT) Message-Id: Subject: Re: compctl bug with beta17 on Linux To: zsh-workers@math.gatech.edu Date: Thu, 9 May 1996 16:15:42 +0200 (MET DST) In-Reply-To: <199605090005.CAA00564@hzoli.ppp.cs.elte.hu> from "Zoltan Hidvegi" at May 9, 96 02:05:07 am From: Thorsten Meinecke Organization: none. Location: Berlin, Germany X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"UDZdO1.0.mN.quVan"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1038 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu In archive/latest/1024, Zoltan Hidvegi wrote: > The problem is that cmdstr is initialised in the middle of get_comp_string > using dupstring() and there is a pushheap() before this and a pophheap() > after this. This means that cmdstr will be freed before returning from > get_comp_string(). Methinks cmdstr is freed by freeheap() in docomplete(), in this case. > [...] After that, the fix is trivial. I beg to differ :-) Stylistical issues aside (freeing a char* before ever using it, even if it's guaranteed to be initialised with NULL), Zoltan's patch will fall over, when for whatever reason there's more than one command position considered in the do/while-loop in get_comp_string(). Invariably this will lead to memory leaks. For example, when quotes and newlines are involved: % somecommand " > anystring " ^ here's the cursor, and completion is requested cmdstr will point to "anystring", but the memory occupied previously by "somecommand" won't never be released. That "anystring" is the result might be seen as a bug in its own right, but who says that something like this will never happen? Your humble servant, Thorsten