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