From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13778 invoked by alias); 22 Mar 2010 23:13:10 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27823 Received: (qmail 24737 invoked from network); 22 Mar 2010 23:12:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received-SPF: pass (ns1.primenet.com.au: SPF record at ntlworld.com designates 81.103.221.48 as permitted sender) Date: Mon, 22 Mar 2010 23:12:34 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Bug with ZLE special variables and traps? Message-ID: <20100322231234.111b3d77@pws-pc> In-Reply-To: <20100322160716.5b81001e@news01> References: <20080919162045.GA22435@ruderich.org> <20090706151644.6BF508027106@bifrost.dotsrc.org> <20090706154309.GA15663@fermat.math.technion.ac.il> <20090706155337.GB15663@fermat.math.technion.ac.il> <20100315164237.GA23224@fermat.math.technion.ac.il> <100320105027.ZM20067@torch.brasslantern.com> <20100322084226.GA26739@fermat.math.technion.ac.il> <100322075703.ZM21762@torch.brasslantern.com> <20100322160716.5b81001e@news01> X-Mailer: Claws Mail 3.7.5 (GTK+ 2.18.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.1 cv=1ggfb5FlKZQUfF3vzm9UBYZ2uTfLsbs/8dSljwg5+mE= c=1 sm=0 a=2UQqGq2-h_QA:10 a=DogomfpGjd0A:10 a=kj9zAlcOel0A:10 a=4UtWO5riAAAA:8 a=NLZqzBF-AAAA:8 a=zXPFWGafcjY2LpNY9rUA:9 a=M_-H5qZqGgGXZ2Quww8A:7 a=oQimJCJxXuxXW9yfP6yu55RNqxMA:4 a=CjuIK1q_8ugA:10 a=Shd8Sdw-9eQA:10 a=_dQi-Dcv4p4A:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 On Mon, 22 Mar 2010 16:07:16 +0000 Peter Stephenson wrote: > --- Src/lex.c 4 Jan 2010 12:21:09 -0000 1.53 > +++ Src/lex.c 22 Mar 2010 16:03:29 -0000 > @@ -249,6 +249,13 @@ lexsave(void) > ls->histdone = histdone; > ls->stophist = stophist; > stophist = 0; > + if (!lstack) { > + /* top level, make this version visible to ZLE */ > + zle_chline = chline; > + /* ensure line stored is NULL-terminated */ > + if (hptr) > + *hptr = '\0'; > + } > ls->hline = chline; > chline = NULL; > ls->hptr = hptr; Oops... I was getting random crashes and valgrind says hptr can be non-NULL when chline has been freed, which is asking for trouble. Index: Src/hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hist.c,v retrieving revision 1.97 diff -p -u -r1.97 hist.c --- Src/hist.c 22 Mar 2010 16:25:59 -0000 1.97 +++ Src/hist.c 22 Mar 2010 23:11:32 -0000 @@ -1171,7 +1171,7 @@ hend(Eprog prog) if (histactive & HA_NOINC) { zfree(chline, hlinesz); zfree(chwords, chwordlen*sizeof(short)); - chline = NULL; + chline = hptr = NULL; chwords = NULL; histactive = 0; unqueue_signals(); @@ -1286,7 +1286,7 @@ hend(Eprog prog) } zfree(chline, hlinesz); zfree(chwords, chwordlen*sizeof(short)); - chline = NULL; + chline = hptr = NULL; chwords = NULL; histactive = 0; if (isset(SHAREHISTORY)? histfileIsLocked() : isset(INCAPPENDHISTORY)) -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/