about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-11-26 10:27:59 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-11-26 10:27:59 +0000
commit0d04d4c31248fe58c67660bbde07ebb892f874a6 (patch)
treeb34f8c9e904914db256a1a90c046db38288a248c
parent0c59f29ddc5d9adb41b1f0f950ae8862b1595ff5 (diff)
downloadzsh-0d04d4c31248fe58c67660bbde07ebb892f874a6.tar.gz
zsh-0d04d4c31248fe58c67660bbde07ebb892f874a6.tar.xz
zsh-0d04d4c31248fe58c67660bbde07ebb892f874a6.zip
24120: termcap string memory allocation was screwy
-rw-r--r--ChangeLog3
-rw-r--r--Src/init.c6
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index afd3085a6..13bb6d5ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2007-11-26  Peter Stephenson  <pws@csr.com>
 
+	* 24120: Src/init.c: memory allocation for termcap strings
+	was screwy, in particular when terminal couldn't move left.
+
 	* c.f. users/12248: Doc/Zsh/.distfiles: zshcalsys.1 was missing
 	from distribution.
 
diff --git a/Src/init.c b/Src/init.c
index 55f32079b..bd582ad2b 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -598,19 +598,22 @@ init_term(void)
 	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 @@ init_term(void)
 
 	/* if there's no termcap entry for clear, use ^L. */
 	if (!tccan(TCCLEARSCREEN)) {
+	    zsfree(tcstr[TCCLEARSCREEN]);
 	    tcstr[TCCLEARSCREEN] = ztrdup("\14");
 	    tclen[TCCLEARSCREEN] = 1;
 	}