summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-04-29 08:43:38 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-04-29 08:43:38 +0000
commitf5ed24f47ef4d2292c327d78440f4aa9d0f04f98 (patch)
treedea492850453ac32399b8d53fed77f44d766ad6e
parentf8220437f22852d72d4a8ab2ed86afb5f5f21cce (diff)
downloadzsh-f5ed24f47ef4d2292c327d78440f4aa9d0f04f98.tar.gz
zsh-f5ed24f47ef4d2292c327d78440f4aa9d0f04f98.tar.xz
zsh-f5ed24f47ef4d2292c327d78440f4aa9d0f04f98.zip
24893: duplicate statusline to avoid crashes when constant
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/zle_refresh.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 172136b39..5c5e49aad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-29  Peter Stephenson  <pws@csr.com>
+
+	* 24893: Src/Zle/zle_refresh.c: duplicate statusline to avoid
+	crashes when it's passed from a constant string.
+
 2008-04-28  Peter Stephenson  <pws@csr.com>
 
 	* unposted: Src/Zle/zle_hist.c: when anchoring a pattern
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index cc0dbe4c0..798541646 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -1418,8 +1418,9 @@ zrefresh(void)
 
     if (statusline) {
 	int outll, outsz;
+	char *statusdup = ztrdup(statusline);
 	ZLE_STRING_T outputline =
-	    stringaszleline(statusline, 0, &outll, &outsz, NULL); 
+	    stringaszleline(statusdup, 0, &outll, &outsz, NULL); 
 
 	rpms.tosln = rpms.ln + 1;
 	nbuf[rpms.ln][winw + 1] = zr_zr;	/* text not wrapped */
@@ -1484,6 +1485,7 @@ zrefresh(void)
 	    snextline(&rpms);
 	}
 	zfree(outputline, outsz);
+	free(statusdup);
     }
     *rpms.s = zr_zr;