summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-01-08 15:07:02 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-01-08 15:07:02 +0000
commit4497b2b1b70bb1646bb4d62c9f5b410f7a6fe536 (patch)
treeca342afaef1abf67a5dd7b2c1fee37a02197d6c1
parent174143dd7c2fc1da1668a216028f0657088aa166 (diff)
downloadzsh-4497b2b1b70bb1646bb4d62c9f5b410f7a6fe536.tar.gz
zsh-4497b2b1b70bb1646bb4d62c9f5b410f7a6fe536.tar.xz
zsh-4497b2b1b70bb1646bb4d62c9f5b410f7a6fe536.zip
24371: bug refreshing large scrolling history entry
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/zle_refresh.c11
2 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 837bf8d60..275280419 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-08  Peter Stephenson  <pws@csr.com>
+
+	* 24371: Src/Zle/zle_refresh.c: potential crash when refreshing
+	scrolling chunk of large history entry.
+
 2008-01-06  Clint Adams  <clint@zsh.org>
 
 	* Chris Lamb: 24365: Completion/Debian/Command/.distfiles,
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index a705f67cf..cdda42287 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -797,7 +797,7 @@ zrefresh(void)
 		(int)ZR_strlen(nbuf[0]) + rpromptw < winw - 1;
     } else {
 /* insert >.... on first line if there is more text before start of screen */
-	memset(nbuf[0], ZWC(' '), lpromptw);
+	ZR_memset(nbuf[0], ZWC(' '), lpromptw);
 	t0 = winw - lpromptw;
 	t0 = t0 > 5 ? 5 : t0;
 	ZR_memcpy(nbuf[0] + lpromptw, ZWS(">...."), t0);
@@ -1133,6 +1133,15 @@ refreshline(int ln)
 	    if (!*ol) {
 		i = (col_cleareol >= 0) ? col_cleareol : nllen;
 		i -= vcs;
+		if (i < 0) {
+		    /*
+		     * This shouldn't be necessary, but it's better
+		     * than a crash if there's a bug somewhere else,
+		     * so report in debug mode.
+		     */
+		    DPUTS(1, "BUG: badly calculated old line width in refresh");
+		    i = 0;
+		}
 		zwrite(nl, i);
 		vcs += i;
 		if (col_cleareol >= 0)