summary refs log tree commit diff
path: root/Src/signals.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/signals.c')
-rw-r--r--Src/signals.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Src/signals.c b/Src/signals.c
index 543d4ab9b..7ec517b7f 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -671,8 +671,11 @@ dosavetrap(int sig, int level)
 	    newshf->funcdef = dupeprog(shf->funcdef, 0);
 	}
 	st->list = newshf;
-    } else {
+    } else if (sigtrapped[sig]) {
 	st->list = sigfuncs[sig] ? dupeprog(sigfuncs[sig], 0) : NULL;
+    } else {
+	DPUTS(sigfuncs[sig], "BUG: sigfuncs not null for untrapped signal");
+	st->list = NULL;
     }
     if (!savetraps)
 	savetraps = znewlinklist();
@@ -789,6 +792,7 @@ removetrap(int sig)
 	 * As in dosavetrap(), don't call removeshfuncnode() because
 	 * that calls back into unsettrap();
 	 */
+	sigfuncs[sig] = NULL;
 	return removehashnode(shfunctab, func);
     } else if (sigfuncs[sig]) {
 	freeeprog(sigfuncs[sig]);