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

Re: Bug#452915: zsh segfaults when doing: export TERM=dumb; export TERM=xterm; export TERM=dumb



I think this should fix it.  Three quarters of this is paranoia.

Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.78
diff -u -r1.78 init.c
--- Src/init.c	26 Sep 2007 10:28:35 -0000	1.78
+++ Src/init.c	26 Nov 2007 10:17:26 -0000
@@ -598,19 +598,22 @@
 	if (tccan(TCUP))
 	    termflags &= ~TERM_NOUP;
 	else {
+	    zsfree(tcstr[TCUP]);
 	    tcstr[TCUP] = NULL;
 	    termflags |= TERM_NOUP;
 	}
 
 	/* most termcaps don't define "bc" because they use \b. */
 	if (!tccan(TCBACKSPACE)) {
+	    zsfree(tcstr[TCBACKSPACE]);
 	    tcstr[TCBACKSPACE] = ztrdup("\b");
 	    tclen[TCBACKSPACE] = 1;
 	}
 
 	/* if there's no termcap entry for cursor left, use backspace. */
 	if (!tccan(TCLEFT)) {
-	    tcstr[TCLEFT] = tcstr[TCBACKSPACE];
+	    zsfree(tcstr[TCLEFT]);
+	    tcstr[TCLEFT] = ztrdup(tcstr[TCBACKSPACE]);
 	    tclen[TCLEFT] = tclen[TCBACKSPACE];
 	}
 
@@ -629,6 +632,7 @@
 
 	/* if there's no termcap entry for clear, use ^L. */
 	if (!tccan(TCCLEARSCREEN)) {
+	    zsfree(tcstr[TCCLEARSCREEN]);
 	    tcstr[TCCLEARSCREEN] = ztrdup("\14");
 	    tclen[TCCLEARSCREEN] = 1;
 	}



-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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