From: Antoine Pitrou Date: Sat, 4 May 2013 21:16:59 +0000 (+0200) Subject: Issue #14173: Avoid crashing when reading a signal handler during interpreter shutdown. X-Git-Tag: v2.7.5~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8931c375a92787662b32a5e07583a0490d8fc34;p=thirdparty%2FPython%2Fcpython.git Issue #14173: Avoid crashing when reading a signal handler during interpreter shutdown. --- diff --git a/Misc/NEWS b/Misc/NEWS index 628ad7653864..0691ad339566 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -34,6 +34,9 @@ Core and Builtins Library ------- +- Issue #14173: Avoid crashing when reading a signal handler during + interpreter shutdown. + - Issue #16316: mimetypes now recognizes the .xz and .txz (.tar.xz) extensions. - Issue #17192: Restore the patch for Issue #10309 which was ommitted diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index d5d628328b14..184b3a91a399 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -321,7 +321,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, @@ -349,8 +352,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,