fix memory leak reported in #3134 (#3135) (#3159)

This commit is contained in:
Alex Gaynor 2016-09-21 23:54:06 -04:00 committed by Paul Kehrer
parent f21ed73a6c
commit 4d5aa3923f

View file

@ -85,6 +85,10 @@ def _encode_name(backend, attributes):
subject = backend._lib.X509_NAME_new()
for attribute in attributes:
name_entry = _encode_name_entry(backend, attribute)
# X509_NAME_add_entry dups the object so we need to gc this copy
name_entry = backend._ffi.gc(
name_entry, backend._lib.X509_NAME_ENTRY_free
)
res = backend._lib.X509_NAME_add_entry(subject, name_entry, -1, 0)
backend.openssl_assert(res == 1)
return subject