PyModule_AddObject steals a reference. Fix all of the double calls to it by adding a Py_INCREF. Also, some other assorted hacks which probably shouldn't be necessary but are at the moment.
diff --git a/src/crypto/x509req.c b/src/crypto/x509req.c
index 07bd44b..c56692b 100644
--- a/src/crypto/x509req.c
+++ b/src/crypto/x509req.c
@@ -425,6 +425,9 @@
return 0;
}
+ /* PyModule_AddObject steals a reference.
+ */
+ Py_INCREF((PyObject *)&crypto_X509Req_Type);
if (PyModule_AddObject(module, "X509Req", (PyObject *)&crypto_X509Req_Type) != 0) {
return 0;
}