Check return value of PyLong_FromLong(X509_get_version()). It might be NULL if
X509_get_version() grows beyond our small int cache.
CID 1058279
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 434729f..848b962 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -903,6 +903,8 @@
     Py_DECREF(issuer);
 
     version = PyLong_FromLong(X509_get_version(certificate) + 1);
+    if (version == NULL)
+        goto fail0;
     if (PyDict_SetItemString(retval, "version", version) < 0) {
         Py_DECREF(version);
         goto fail0;