about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-11-19 16:53:09 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-11-19 16:53:09 +0000
commitbcfddb03c7b1c0491a7cdc9ef6da9e7d9eaa18df (patch)
tree248dde3240effd3102ed17bb3d562bb94fb4c1d8
parentf596decec4341aef09d8b3601c9a9c6c5fa55ec7 (diff)
downloadzsh-bcfddb03c7b1c0491a7cdc9ef6da9e7d9eaa18df.tar.gz
zsh-bcfddb03c7b1c0491a7cdc9ef6da9e7d9eaa18df.tar.xz
zsh-bcfddb03c7b1c0491a7cdc9ef6da9e7d9eaa18df.zip
users/12230: fix problem setting killring to zero size
-rw-r--r--ChangeLog4
-rw-r--r--Src/Zle/zle_params.c22
2 files changed, 16 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 86b43f78b..b415eb82d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-11-19  Peter Stephenson  <pws@csr.com>
 
+	* users/12230: Src/Zle/zle_params.c: if killring was set
+	to empty array, kringsize was zero but kring was unset,
+	causing unhealthy effects in cut().
+
 	* unposted: from Eric Mangold: Completion/Unix/Command/_twisted:
 	update.
 
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index dffe57161..817d6e57a 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -497,16 +497,18 @@ set_killring(UNUSED(Param pm), char **x)
 	 */
 	int kpos = 0;
 	kringsize = arrlen(x);
-	kring = (Cutbuffer)zshcalloc(kringsize * sizeof(struct cutbuffer));
-	for (p = x; *p; p++) {
-	    int n, len = strlen(*p);
-	    kptr = kring + kpos;
-
-	    kptr->buf = stringaszleline(*p, 0, &n, NULL, NULL);
-	    kptr->len = n;
-
-	    zfree(*p, len+1);
-	    kpos = (kpos + kringsize -1 ) % kringsize;
+	if (kringsize != 0) {
+	    kring = (Cutbuffer)zshcalloc(kringsize * sizeof(struct cutbuffer));
+	    for (p = x; *p; p++) {
+		int n, len = strlen(*p);
+		kptr = kring + kpos;
+
+		kptr->buf = stringaszleline(*p, 0, &n, NULL, NULL);
+		kptr->len = n;
+
+		zfree(*p, len+1);
+		kpos = (kpos + kringsize -1 ) % kringsize;
+	    }
 	}
 	free(x);
     }