about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-11-23 16:29:50 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-11-23 16:29:50 +0000
commit138c5df2bb1b16f712374ec1bd8024a143856793 (patch)
tree1e2fff8a0bbaed1e1de4cc96d037caa6e747777b
parent5141e68daa20caa8523361d5dff63e9384c30191 (diff)
downloadzsh-138c5df2bb1b16f712374ec1bd8024a143856793.tar.gz
zsh-138c5df2bb1b16f712374ec1bd8024a143856793.tar.xz
zsh-138c5df2bb1b16f712374ec1bd8024a143856793.zip
20576: fix core dump on TRAPEXIT
-rw-r--r--ChangeLog6
-rw-r--r--Src/signals.c14
2 files changed, 19 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 9b69e96ce..b61cf897f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-11-23  Peter Stephenson  <pws@csr.com>
+
+	* 20576: Src/signals.c: 20572 caused core dump when
+	trying to run a signal where the function had already
+	been removed.
+
 2004-11-22  Peter Stephenson  <pws@csr.com>
 
 	* 20572: Doc/Zsh/builtins.yo, Src/builtin.c, Src/exec.c,
diff --git a/Src/signals.c b/Src/signals.c
index 9959d3c31..785ff159e 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -1010,7 +1010,19 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
 	HashNode hn = gettrapnode(sig, 0);
 
 	args = znewlinklist();
-	name = ztrdup(hn->nam);
+	/*
+	 * In case of multiple names, try to get
+	 * a hint of the name in use from the function table.
+	 * In special cases, e.g. EXIT traps, the function
+	 * has already been removed.  Then it's OK to
+	 * use the standard name.
+	 */
+	if (hn) {
+	    name = ztrdup(hn->nam);
+	} else {
+	    name = (char *) zalloc(5 + strlen(sigs[sig]));
+	    sprintf(name, "TRAP%s", sigs[sig]);
+	}
 	zaddlinknode(args, name);
 	sprintf(num, "%d", sig);
 	zaddlinknode(args, num);