incref the X509Req when returning an X509Name from get_subject which refers to it; this prevents a segfault if the X509Name outlives the X509Req; update docs to reflect this and to reflect previous similar changes which were apparently made to X509.get_subject and X509.get_issuer
diff --git a/src/crypto/x509req.c b/src/crypto/x509req.c
index d551de4..7ad1a14 100644
--- a/src/crypto/x509req.c
+++ b/src/crypto/x509req.c
@@ -26,6 +26,7 @@
{
crypto_X509NameObj *crypto_X509Name_New(X509_NAME *, int);
X509_NAME *name;
+ crypto_X509NameObj* pyname;
if (!PyArg_ParseTuple(args, ":get_subject"))
return NULL;
@@ -35,8 +36,11 @@
exception_from_error_queue();
return NULL;
}
-
- return (PyObject *)crypto_X509Name_New(name, 0);
+ if ((pyname = crypto_X509Name_New(name, 0)) != NULL) {
+ pyname->parent_cert = (PyObject *)self;
+ Py_INCREF(self);
+ }
+ return (PyObject *)pyname;
}
static char crypto_X509Req_get_pubkey_doc[] = "\n\