]> granicus.if.org Git - python/commitdiff
Fix math.factorial KeyboardInterrupt segfault. Thanks Amaury for report and diagnosis.
authorMark Dickinson <mdickinson@enthought.com>
Thu, 25 Oct 2012 09:46:28 +0000 (10:46 +0100)
committerMark Dickinson <mdickinson@enthought.com>
Thu, 25 Oct 2012 09:46:28 +0000 (10:46 +0100)
Misc/NEWS
Modules/mathmodule.c

index 5438245ba4ceade18cf94fe67e63d6ac1c53205c..e6948d70e212197346c561e06c2076011fa6efaa 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -132,6 +132,9 @@ Core and Builtins
 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.
index 2c4cc7331b71fdcf345f4722e79d75c0f16c4257..142eca468a2c30458394a2499c4aae7b47614138 100644 (file)
@@ -1330,14 +1330,13 @@ factorial_odd_part(unsigned long n)
         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 */