diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2020-11-27 15:22:30 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-27 16:22:30 -0500 |
commit | 09b5d7071846a7abdb8061711ac0d2e561f7260a (patch) | |
tree | 6be38a35f4bfcfcfac4536ea31091b0646cb5034 /src/OpenSSL/crypto.py | |
parent | 3562df8732f66848342874526d0ce12392d7d62e (diff) | |
download | pyopenssl-git-09b5d7071846a7abdb8061711ac0d2e561f7260a.tar.gz |
fix a memleak (#967)
* fix a memleak
* black
Diffstat (limited to 'src/OpenSSL/crypto.py')
-rw-r--r-- | src/OpenSSL/crypto.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py index 84f92b1..4265525 100644 --- a/src/OpenSSL/crypto.py +++ b/src/OpenSSL/crypto.py @@ -1017,9 +1017,20 @@ class X509Req(object): """ exts = [] native_exts_obj = _lib.X509_REQ_get_extensions(self._req) + native_exts_obj = _ffi.gc( + native_exts_obj, + lambda x: _lib.sk_X509_EXTENSION_pop_free( + x, + _ffi.addressof(_lib._original_lib, "X509_EXTENSION_free"), + ), + ) + for i in range(_lib.sk_X509_EXTENSION_num(native_exts_obj)): ext = X509Extension.__new__(X509Extension) - ext._extension = _lib.sk_X509_EXTENSION_value(native_exts_obj, i) + extension = _lib.X509_EXTENSION_dup( + _lib.sk_X509_EXTENSION_value(native_exts_obj, i) + ) + ext._extension = _ffi.gc(extension, _lib.X509_EXTENSION_free) exts.append(ext) return exts |