about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2014-11-13 09:58:34 +0100
committerOliver Kiddle <opk@zsh.org>2014-11-13 09:58:34 +0100
commit99382e689dc41731ee225221964d58732ff7a4e6 (patch)
treec356a9806e974c528edf3ec7b77272b13ea4a465 /Src/Zle
parente33411990e1353e5d39379adb56e325ab92ce28c (diff)
downloadzsh-99382e689dc41731ee225221964d58732ff7a4e6.tar.gz
zsh-99382e689dc41731ee225221964d58732ff7a4e6.tar.xz
zsh-99382e689dc41731ee225221964d58732ff7a4e6.zip
33669: allow an empty line to be yanked with yy
This  by allocating 1 byte instead of 0 for the empty buffer.
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/zle_utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 03a2bdca7..f56063e82 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -916,7 +916,7 @@ cut(int i, int ct, int flags)
 void
 cuttext(ZLE_STRING_T line, int ct, int flags)
 {
-    if (!ct || zmod.flags & MOD_NULL)
+    if (!(ct || vilinerange) ||  zmod.flags & MOD_NULL)
 	return;
 
     UNMETACHECK();
@@ -989,8 +989,9 @@ cuttext(ZLE_STRING_T line, int ct, int flags)
 	cutbuf.buf = s;
 	cutbuf.len += ct;
     } else {
+	/* don't alloc 0 bytes; length 0 occurs for blank lines in vi mode */
 	cutbuf.buf = realloc((char *)cutbuf.buf,
-			     (cutbuf.len + ct) * ZLE_CHAR_SIZE);
+			     (cutbuf.len + (ct ? ct : 1)) * ZLE_CHAR_SIZE);
 	ZS_memcpy(cutbuf.buf + cutbuf.len, line, ct);
 	cutbuf.len += ct;
     }