I found my memory leak origin. I didn't free an X509 object when I called SSL_get_peer_certificate function (missing X509_free() call). Hope it will be useful for others
Cheers!! From: hicham55...@hotmail.com To: openssl-users@openssl.org Subject: RE: Memory leak in ssl3_get_server_certificate Date: Thu, 3 Apr 2014 15:11:19 +0000 Well, I found out where it's defined. It's a MACRO definition ( IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname ....). I'm still investigating the leak .... Regards From: hicham55...@hotmail.com To: openssl-users@openssl.org Subject: Memory leak in ssl3_get_server_certificate Date: Thu, 3 Apr 2014 14:41:27 +0000 Hello all, I found a memory leak when using ssl_connect function. Bellow the valgrind trace: ==12028== 37,600 (1,040 direct, 36,560 indirect) bytes in 10 blocks are definitely lost in loss record 12 of 27 ==12028== at 0x40053C0: malloc (vg_replace_malloc.c:149) ==12028== by 0x4185C8E: default_malloc_ex (mem.c:79) ==12028== by 0x41861FB: CRYPTO_malloc (mem.c:308) ==12028== by 0x4226309: asn1_item_ex_combine_new (tasn_new.c:191) ==12028== by 0x4226064: ASN1_item_ex_new (tasn_new.c:85) ==12028== by 0x42283F4: ASN1_item_ex_d2i (tasn_dec.c:400) ==12028== by 0x4227D86: ASN1_item_d2i (tasn_dec.c:136) ==12028== by 0x4221EE4: d2i_X509 (x_x509.c:141) ==12028== by 0x40E8A8F: ssl3_get_server_certificate (s3_clnt.c:1136) ==12028== by 0x40E7508: ssl3_connect (s3_clnt.c:334) ==12028== by 0x410C477: SSL_connect (ssl_lib.c:949) ==12028== by 0x826CA05: ssl_Connect (ssl_ossl_interf.c:991) Do you have any idea were d2i_X509 function i defined? Because I can't find the x_x509.c file in openssl 1.0.1e version Regards