Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug with ZLE special variables and traps?



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



Messages sorted by: Reverse Date, Date, Thread, Author