diff options
author | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2012-02-18 12:51:11 -0500 |
---|---|---|
committer | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2012-02-18 12:54:39 -0500 |
commit | 4b3c25f4b872c288ace179c68cebc46cce5039aa (patch) | |
tree | 7411098cba3fec4c2b23fb79a54b3349ebf56eac | |
parent | a6ddd108cf8e70c4037065143f968e994f5ef581 (diff) | |
download | pycrypto-4b3c25f4b872c288ace179c68cebc46cce5039aa.tar.gz |
Fix segfault if Crypto.Random.new is missing for some reason.
This should never happen, but we're already checking that Crypto.Random.new is
callable, so we might as well also check that Crypto.Random.new exists. Also,
fixing this should silence an (arguably false-positive) error emitted by
cpychecker (a static analysis tool used by the Fedora project).
-rw-r--r-- | src/_fastmath.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/_fastmath.c b/src/_fastmath.c index 8c1a517..4b5dede 100644 --- a/src/_fastmath.c +++ b/src/_fastmath.c @@ -1136,6 +1136,11 @@ getRNG (void) module_dict = PyModule_GetDict (module); Py_DECREF (module); new_func = PyDict_GetItemString (module_dict, "new"); + if (new_func == NULL) { + PyErr_SetString (PyExc_RuntimeError, + "Crypto.Random.new is missing."); + return NULL; + } if (!PyCallable_Check (new_func)) { PyErr_SetString (PyExc_RuntimeError, |