about summary refs log tree commit diff
diff options
context:
space:
mode:
-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)