summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-10-26 10:00:54 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-10-26 10:00:54 +0000
commit11ca38c6d99192856d33254c504114d4ba8cd258 (patch)
tree9c8269d5b0df54a190e91f90d80d4dc705393d20
parent8b5158424637834f242bb1e2114dee4ac7cca328 (diff)
downloadzsh-11ca38c6d99192856d33254c504114d4ba8cd258.tar.gz
zsh-11ca38c6d99192856d33254c504114d4ba8cd258.tar.xz
zsh-11ca38c6d99192856d33254c504114d4ba8cd258.zip
users/20825: fix crash when complex completion hooks.
get_undo_current_change() needs protecting against execution in
completion environment.
-rw-r--r--ChangeLog6
-rw-r--r--Src/Zle/zle_utils.c17
2 files changed, 23 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index e26e62e5f..b2291f5b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-26  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* users/20825: Src/Zle/zle_utils.c: get_undo_current_change()
+	needs same protection as mkundoent() for execution within
+	completion.
+
 2015-10-25  Daniel Shahaf  <d.s@daniel.shahaf.name>
 
 	* 36962: Completion/Unix/Command/_git: _git: Fix completion of
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 714d911a6..ffff8fd1c 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1739,9 +1739,26 @@ zlecallhook(char *name, char *arg)
 zlong
 get_undo_current_change(UNUSED(Param pm))
 {
+    int remetafy;
+
+    /*
+     * Yuk: we call this from within the completion system,
+     * so we need to convert back to the form which can be
+     * copied into undo entries.
+     */
+    if (zlemetaline != NULL) {
+	unmetafy_line();
+	remetafy = 1;
+    } else
+	remetafy = 0;
+
     /* add entry for any pending changes */
     mkundoent();
     setlastline();
+
+    if (remetafy)
+	metafy_line();
+
     return undo_changeno;
 }