faulthandler: fix unregister() if it is called before register()

Fix a crash: don't read from NULL.
This commit is contained in:
Victor Stinner 2011-04-08 12:48:15 +02:00
parent 7ede59d77a
commit cfa7123ef1
2 changed files with 5 additions and 1 deletions

View file

@ -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.

View file

@ -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);