mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
faulthandler: fix unregister() if it is called before register()
Fix a crash: don't read from NULL.
This commit is contained in:
parent
7ede59d77a
commit
cfa7123ef1
2 changed files with 5 additions and 1 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue