[Python-checkins] cpython (3.2): Fix math.factorial KeyboardInterrupt segfault. Thanks Amaury for report and

mark.dickinson python-checkins at python.org
Thu Oct 25 11:52:25 CEST 2012


http://hg.python.org/cpython/rev/b4bfcf7a4773
changeset:   79933:b4bfcf7a4773
branch:      3.2
parent:      79927:997ab4f1530f
user:        Mark Dickinson <mdickinson at enthought.com>
date:        Thu Oct 25 10:46:28 2012 +0100
summary:
  Fix math.factorial KeyboardInterrupt segfault.  Thanks Amaury for report and diagnosis.

files:
  Misc/NEWS            |  3 +++
  Modules/mathmodule.c |  7 +++----
  2 files changed, 6 insertions(+), 4 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -132,6 +132,9 @@
 Library
 -------
 
+- Issue #16305: Fix a segmentation fault occurring when interrupting
+  math.factorial.
+
 - Issue #14398: Fix size truncation and overflow bugs in the bz2 module.
 
 - Issue #16220: wsgiref now always calls close() on an iterable response.
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -1330,14 +1330,13 @@
         Py_DECREF(outer);
         outer = tmp;
     }
-
-    goto done;
+    Py_DECREF(inner);
+    return outer;
 
   error:
     Py_DECREF(outer);
-  done:
     Py_DECREF(inner);
-    return outer;
+    return NULL;
 }
 
 /* Lookup table for small factorial values */

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


More information about the Python-checkins mailing list