最近我的应用程序在排除内存泄漏时,发现使用openssl的模块,有内存泄漏。求路过的大神帮忙解答。
在使用valgrind工具,检测内存泄露的过程中,在ssl3_get_server_certificate函数调用栈中,提示如下信息:
==22131== HEAP SUMMARY:
==22131== in use at exit: 124,949 bytes in 3,583 blocks
==22131== total heap usage: 5,977 allocs, 2,394 frees, 525,333 bytes allocated
==22131==
==22131== 1,048 (56 direct, 992 indirect) bytes in 1 blocks are definitely lost in loss record 840 of 867
==22131== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22131== by 0x51097BD: CRYPTO_malloc (in /home/test/Desktop/TestSSL/libcrypto.so.1.0.0)
==22131== by 0x519BD89: EVP_PKEY_new (in /home/test/Desktop/TestSSL/libcrypto.so.1.0.0)
==22131== by 0x51ABECF: X509_PUBKEY_get (in /home/test/Desktop/TestSSL/libcrypto.so.1.0.0)
==22131== by 0x4E5E64D: ssl3_get_server_certificate (in /home/test/Desktop/TestSSL/libssl.so.1.0.0)
==22131== by 0x4E5FC61: ssl3_connect (in /home/test/Desktop/TestSSL/libssl.so.1.0.0)
==22131== by 0x40368E: main (in /home/test/Desktop/TestSSL/test)
==22131==
==22131== 4,789 (184 direct, 4,605 indirect) bytes in 1 blocks are definitely lost in loss record 863 of 867
==22131== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22131== by 0x51097BD: CRYPTO_malloc (in /home/test/Desktop/TestSSL/libcrypto.so.1.0.0)
==22131== by 0x51B195C: asn1_item_ex_combine_new (in /home/test/Desktop/TestSSL/libcrypto.so.1.0.0)
==22131== by 0x51B4771: ASN1_item_ex_d2i (in /home/test/Desktop/TestSSL/libcrypto.so.1.0.0)
==22131== by 0x51B4E13: ASN1_item_d2i (in /home/test/Desktop/TestSSL/libcrypto.so.1.0.0)
==22131== by 0x4E5E44B: ssl3_get_server_certificate (in /home/test/Desktop/TestSSL/libssl.so.1.0.0)
==22131== by 0x4E5FC61: ssl3_connect (in /home/test/Desktop/TestSSL/libssl.so.1.0.0)
==22131== by 0x40368E: main (in /home/test/Desktop/TestSSL/test)
路过的大神,帮忙看看,有遇到类似问题的吗????
openssl版本是openssl-1.0.1e