about summary refs log tree commit diff
diff options
context:
space:
mode:
-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);