Skip to content

Commit 40b35a4

Browse files
committed
Free X509 in WolfSSLX509.__del__
1 parent c5ed261 commit 40b35a4

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

wolfssl/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ def __init__(self, session):
100100
if self.native_object == _ffi.NULL:
101101
raise SSLError("Unable to get internal WOLFSSL_X509 from wolfSSL")
102102

103+
def __del__(self):
104+
if getattr(self, 'native_object', None) is not None \
105+
and self.native_object != _ffi.NULL:
106+
_lib.wolfSSL_X509_free(self.native_object)
107+
self.native_object = _ffi.NULL
108+
103109
def get_subject_cn(self):
104110
cnPtr = _lib.wolfSSL_X509_get_subjectCN(self.native_object)
105111
if cnPtr == _ffi.NULL:

0 commit comments

Comments
 (0)