From: Mark Dickinson Date: Thu, 25 Oct 2012 09:46:28 +0000 (+0100) Subject: Fix math.factorial KeyboardInterrupt segfault. Thanks Amaury for report and diagnosis. X-Git-Tag: v3.2.4rc1~415 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76464494bc1a6779cc4839a28238fb7ea4104a5a;p=thirdparty%2FPython%2Fcpython.git Fix math.factorial KeyboardInterrupt segfault. Thanks Amaury for report and diagnosis. --- diff --git a/Misc/NEWS b/Misc/NEWS index 5438245ba4ce..e6948d70e212 100644 --- 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. diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 2c4cc7331b71..142eca468a2c 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -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 */