From 11ca38c6d99192856d33254c504114d4ba8cd258 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Mon, 26 Oct 2015 10:00:54 +0000
Subject: users/20825: fix crash when complex completion hooks.
get_undo_current_change() needs protecting against execution in
completion environment.
---
ChangeLog | 6 ++++++
Src/Zle/zle_utils.c | 17 +++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index e26e62e5f..b2291f5b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-26 Peter Stephenson
+
+ * 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
* 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;
}
--
cgit 1.4.1