Skip to content

Commit

Permalink
Provide a destructor for the CRL object (#690)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jeremycline authored and alex committed Sep 8, 2017
1 parent 332848f commit 9e15eca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/OpenSSL/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 9e15eca

Please sign in to comment.