summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/Zle/zle_keymap.c7
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 63c80e04d..6deb834d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,9 @@
 
 2016-11-02  Barton E. Schaefer  <schaefer@zsh.org>
 
+	* 39813: Src/Zle/zle_keymap.c: fix keybuflen after ungetting
+	extra keys from the end of keybuf in getkeymapcmd().
+
 	* 39811: Src/Zle/zle_vi.c: vi-repeat-change must not be the
 	"motion" of vi-change, lest it infinitely repeat itself.
 
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 3db4207d9..34c9c686e 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -135,7 +135,10 @@ mod_export HashTable keymapnamtab;
 /**/
 char *keybuf;
 
-static int keybuflen, keybufsz = 20;
+/**/
+int keybuflen;
+
+static int keybufsz = 20;
 
 /* last command executed with execute-named-command */
 
@@ -1622,7 +1625,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
 	ungetbytes(keybuf+lastlen, keybuflen);
 	if(vichgflag)
 	    vichgbufptr -= keybuflen;
-	keybuf[lastlen] = 0;
+	keybuf[keybuflen = lastlen] = 0;
     }
     *funcp = func;
     *strp = str;