summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-04-08 10:48:15 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-04-08 10:48:15 (GMT)
commitcfa7123ef108452dd402e3cdcec772be28872e2f (patch)
tree679f3380a96b416bb75a8e40e1488a016a7a2045
parent7ede59d77a9b21c5c021d1b9a4289aba11509fdd (diff)
downloadcpython-cfa7123ef108452dd402e3cdcec772be28872e2f.zip
cpython-cfa7123ef108452dd402e3cdcec772be28872e2f.tar.gz
cpython-cfa7123ef108452dd402e3cdcec772be28872e2f.tar.bz2
faulthandler: fix unregister() if it is called before register()
Fix a crash: don't read from NULL.
-rw-r--r--Doc/library/faulthandler.rst3
-rw-r--r--Modules/faulthandler.c3
2 files changed, 5 insertions, 1 deletions
diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst
index 106da45..c0b6625 100644
--- a/Doc/library/faulthandler.rst
+++ b/Doc/library/faulthandler.rst
@@ -97,7 +97,8 @@ Dump the traceback on a user signal
.. function:: unregister(signum)
Unregister a user signal: uninstall the handler of the *signum* signal
- installed by :func:`register`.
+ installed by :func:`register`. Return ``True`` if the signal was registered,
+ ``False`` otherwise.
Not available on Windows.
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 76cadf3..1132036 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -694,6 +694,9 @@ faulthandler_unregister_py(PyObject *self, PyObject *args)
if (!check_signum(signum))
return NULL;
+ if (user_signals == NULL)
+ Py_RETURN_FALSE;
+
user = &user_signals[signum];
change = faulthandler_unregister(user, signum);
return PyBool_FromLong(change);