[openssl-users] [openss-users] How to correctly shutdown for connection to avoid memory leak

Jerry OELoo oyljerry at gmail.com
Mon Apr 27 09:20:00 UTC 2015

I am using openssl 1.0.2 to do some ssl connection, now I am facing
some memory leak issue.

ssl = SSL_new(m_ctx);
sbio = BIO_new_socket(server, BIO_NOCLOSE);


//After handle, release resource

Now I have some questions about above code as I think there is some leak in it.
1) As I used BIO_NOCLOSE, should I free for BIO_new_socket
2) from SSL_shutdown. I found below, so Should I call SSL_shutdown twice?
0 The shutdown is not yet finished. Call SSL_shutdown() for a second
time, if a bidirectional shutdown shall be performed. The output of
SSL_get_error may be misleading, as an erroneous SSL_ERROR_SYSCALL may
be flagged even though no error occurred.
3) It seems I missing SSL_free(), So when I do not need this ssl
object, I should call SSL_free(), right?


Rejoice,I Desire!

More information about the openssl-users mailing list