summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDwayne C. Litzenberger <dlitz@dlitz.net>2012-04-25 16:08:02 -0400
committerDwayne C. Litzenberger <dlitz@dlitz.net>2012-04-25 16:08:02 -0400
commit88b4a886ccffef2f6cdbd20f8c983eb5ded1c813 (patch)
tree10de5895572a5158f8da950b6323ffa2916aad6b /src
parent95d65366e9ac7e194bf8317d69785c9a5b877790 (diff)
downloadpycrypto-88b4a886ccffef2f6cdbd20f8c983eb5ded1c813.tar.gz
_fastmath: missing Py_BLOCK_THREADS on isPrime(1)
When _fastmath is present, the following code caused the Python interpreter to abort with a fatal error: from Crypto.Util.number import isPrime isPrime(1) # Fatal Python error: PyEval_SaveThread: NULL tstate Bug report: https://bugs.launchpad.net/pycrypto/+bug/988431
Diffstat (limited to 'src')
-rw-r--r--src/_fastmath.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/_fastmath.c b/src/_fastmath.c
index 4b5dede..41734aa 100644
--- a/src/_fastmath.c
+++ b/src/_fastmath.c
@@ -1342,8 +1342,11 @@ rabinMillerTest (mpz_t n, int rounds, PyObject *randfunc)
}
Py_BEGIN_ALLOW_THREADS;
- if ((mpz_tstbit (n, 0) == 0) || (mpz_cmp_ui (n, 3) < 0))
- return (mpz_cmp_ui (n, 2) == 0);
+ if ((mpz_tstbit (n, 0) == 0) || (mpz_cmp_ui (n, 3) < 0)) {
+ return_val = (mpz_cmp_ui (n, 2) == 0);
+ Py_BLOCK_THREADS;
+ return return_val;
+ }
mpz_init (tmp);
mpz_init (n_1);