summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Cline <jeremy@jcline.org>2017-09-07 20:11:08 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2017-09-07 20:11:08 -0400
commit9e15eca29625f0aa87635a613b093ba1ecaa28fb (patch)
tree8ebf52b800ac4d99dd58dd7d2b2e76379f862926
parent332848f861b07f4475fb4d8a59387c0fa0a8e7f4 (diff)
downloadpyopenssl-9e15eca29625f0aa87635a613b093ba1ecaa28fb.tar.gz
Provide a destructor for the CRL object (#690)
This frees the memory allocated for the CRL object. Prior to this commit, the following script would leak memory: ``` from OpenSSL.crypto import load_crl, FILETYPE_PEM crl = """ -----BEGIN X509 CRL----- MIIBfDCB5jANBgkqhkiG9w0BAQsFADCBoDELMAkGA1UEBhMCVVMxCzAJBgNVBAgT Ak5DMRAwDgYDVQQHEwdSYWxlaWdoMRcwFQYDVQQKEw5GZWRvcmEgUHJvamVjdDEP MA0GA1UECxMGZmVkbXNnMQ8wDQYDVQQDEwZmZWRtc2cxDzANBgNVBCkTBmZlZG1z ZzEmMCQGCSqGSIb3DQEJARYXYWRtaW5AZmVkb3JhcHJvamVjdC5vcmcXDTE3MDYx NTIxMDMwOFoXDTM3MDYxMDIxMDMwOFowFDASAgECFw0xMjA3MTUyMTE4NTJaMA0G CSqGSIb3DQEBCwUAA4GBAGOBuDxmRFNcYP71LBsCOfFzKij00qpxM01d5/G6+0kM WJT8oTajMQoY6oISvQDq6TkwEoKc1yl6Ld1/XTtCNOhbybzRBAVf/Lxi/nRPP1JO qOdZs5jMLLQq1mRJz+MgKHHTDlnvpbjHMuyTss1RblFDr4iZPHMcBNKPGIj3pmpA -----END X509 CRL----- """ for _ in range(0, 1000000): load_crl(FILETYPE_PEM, crl) ``` Signed-off-by: Jeremy Cline <jeremy@jcline.org>
-rw-r--r--src/OpenSSL/crypto.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index 4f7e4d8..4255358 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -2898,7 +2898,7 @@ def load_crl(type, buffer):
_raise_current_error()
result = CRL.__new__(CRL)
- result._crl = crl
+ result._crl = _ffi.gc(crl, _lib.X509_CRL_free)
return result