[Python-checkins] cpython: faulthandler: fix unregister() if it is called before register()

victor.stinner python-checkins at python.org
Fri Apr 8 12:59:13 CEST 2011


http://hg.python.org/cpython/rev/145d0a56c8bd
changeset:   69205:145d0a56c8bd
parent:      69203:5ec2695c9c15
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Fri Apr 08 12:48:15 2011 +0200
summary:
  faulthandler: fix unregister() if it is called before register()

Fix a crash: don't read from NULL.

files:
  Doc/library/faulthandler.rst |  3 ++-
  Modules/faulthandler.c       |  3 +++
  2 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst
--- a/Doc/library/faulthandler.rst
+++ b/Doc/library/faulthandler.rst
@@ -97,7 +97,8 @@
 .. 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
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -694,6 +694,9 @@
     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);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list