summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDwayne C. Litzenberger <dlitz@dlitz.net>2012-02-18 12:51:11 -0500
committerDwayne C. Litzenberger <dlitz@dlitz.net>2012-02-18 12:54:39 -0500
commit4b3c25f4b872c288ace179c68cebc46cce5039aa (patch)
tree7411098cba3fec4c2b23fb79a54b3349ebf56eac /src
parenta6ddd108cf8e70c4037065143f968e994f5ef581 (diff)
downloadpycrypto-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).
Diffstat (limited to 'src')
-rw-r--r--src/_fastmath.c5
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,