zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: Bug with ZLE special variables and traps?
Date: Mon, 22 Mar 2010 23:12:34 +0000	[thread overview]
Message-ID: <20100322231234.111b3d77@pws-pc> (raw)
In-Reply-To: <20100322160716.5b81001e@news01>

On Mon, 22 Mar 2010 16:07:16 +0000
Peter Stephenson <pws@csr.com> 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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


      reply	other threads:[~2010-03-22 23:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <c16a574a0809181450t61a5b5ddq2e80797fde37636e@mail.gmail.com>
     [not found] ` <20080919162045.GA22435@ruderich.org>
     [not found]   ` <20090706151644.6BF508027106@bifrost.dotsrc.org>
     [not found]     ` <20090706154309.GA15663@fermat.math.technion.ac.il>
     [not found]       ` <20090706155337.GB15663@fermat.math.technion.ac.il>
     [not found]         ` <20100315164237.GA23224@fermat.math.technion.ac.il>
     [not found]           ` <100320105027.ZM20067@torch.brasslantern.com>
     [not found]             ` <20100322084226.GA26739@fermat.math.technion.ac.il>
2010-03-22 14:57               ` Bart Schaefer
2010-03-22 16:07                 ` Peter Stephenson
2010-03-22 23:12                   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100322231234.111b3d77@pws-pc \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).