Skip to content

Commit 7646449

Browse files
committed
Fix math.factorial KeyboardInterrupt segfault. Thanks Amaury for report and diagnosis.
1 parent 837cd06 commit 7646449

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ Core and Builtins
132132
Library
133133
-------
134134

135+
- Issue #16305: Fix a segmentation fault occurring when interrupting
136+
math.factorial.
137+
135138
- Issue #14398: Fix size truncation and overflow bugs in the bz2 module.
136139

137140
- Issue #16220: wsgiref now always calls close() on an iterable response.

Modules/mathmodule.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,14 +1330,13 @@ factorial_odd_part(unsigned long n)
13301330
Py_DECREF(outer);
13311331
outer = tmp;
13321332
}
1333-
1334-
goto done;
1333+
Py_DECREF(inner);
1334+
return outer;
13351335

13361336
error:
13371337
Py_DECREF(outer);
1338-
done:
13391338
Py_DECREF(inner);
1340-
return outer;
1339+
return NULL;
13411340
}
13421341

13431342
/* Lookup table for small factorial values */

0 commit comments

Comments
 (0)