summaryrefslogtreecommitdiff
path: root/OpenSSL/ssl/context.c
diff options
context:
space:
mode:
authorJean-Paul Calderone <exarkun@twistedmatrix.com>2012-03-10 18:03:47 -0800
committerJean-Paul Calderone <exarkun@twistedmatrix.com>2012-03-10 18:03:47 -0800
commit0beed1c968ea4511cbe8515effed7acd2a715b48 (patch)
tree03157648605d43b961e50c4a398f27db7958c48e /OpenSSL/ssl/context.c
parentbc2c186728161ceff19e7fd6db1dfab907c723a4 (diff)
parent4cc06a7ab794aa55f4a55a5757adebadd9151fc3 (diff)
downloadpyopenssl-0beed1c968ea4511cbe8515effed7acd2a715b48.tar.gz
Fix a variety of crashes on PyPy or on various builds of OpenSSL
Diffstat (limited to 'OpenSSL/ssl/context.c')
-rw-r--r--OpenSSL/ssl/context.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/OpenSSL/ssl/context.c b/OpenSSL/ssl/context.c
index 0b9f4b6..e971c0a 100644
--- a/OpenSSL/ssl/context.c
+++ b/OpenSSL/ssl/context.c
@@ -1249,7 +1249,7 @@ ssl_Context_init(ssl_ContextObj *self, int i_method) {
#ifdef OPENSSL_NO_SSL2
PyErr_SetString(PyExc_ValueError, "SSLv2_METHOD not supported by this version of OpenSSL");
return NULL;
-#else
+#else
method = SSLv2_method();
#endif
break;
@@ -1268,6 +1268,11 @@ ssl_Context_init(ssl_ContextObj *self, int i_method) {
}
self->ctx = SSL_CTX_new(method);
+ if (self->ctx == NULL) {
+ exception_from_error_queue(ssl_Error);
+ return NULL;
+ }
+
Py_INCREF(Py_None);
self->passphrase_callback = Py_None;
Py_INCREF(Py_None);