summaryrefslogtreecommitdiffstats
path: root/Modules/signalmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-05-04 21:16:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-05-04 21:16:59 (GMT)
commitc8c952ce2a77343b6fe87a9534026b4b34011322 (patch)
tree2dda637adc73ae67d24a27e39456e9922be2b333 /Modules/signalmodule.c
parent957a23b0883c1d92f4d5c5de2459319615a8ed34 (diff)
downloadcpython-c8c952ce2a77343b6fe87a9534026b4b34011322.zip
cpython-c8c952ce2a77343b6fe87a9534026b4b34011322.tar.gz
cpython-c8c952ce2a77343b6fe87a9534026b4b34011322.tar.bz2
Issue #14173: Avoid crashing when reading a signal handler during interpreter shutdown.
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r--Modules/signalmodule.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 0cc7237..fbe1bb7 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -344,7 +344,10 @@ signal_signal(PyObject *self, PyObject *args)
Handlers[sig_num].tripped = 0;
Py_INCREF(obj);
Handlers[sig_num].func = obj;
- return old_handler;
+ if (old_handler != NULL)
+ return old_handler;
+ else
+ Py_RETURN_NONE;
}
PyDoc_STRVAR(signal_doc,
@@ -372,8 +375,13 @@ signal_getsignal(PyObject *self, PyObject *args)
return NULL;
}
old_handler = Handlers[sig_num].func;
- Py_INCREF(old_handler);
- return old_handler;
+ if (old_handler != NULL) {
+ Py_INCREF(old_handler);
+ return old_handler;
+ }
+ else {
+ Py_RETURN_NONE;
+ }
}
PyDoc_STRVAR(getsignal_doc,