ustream-openssl: fix BIO_method memory leak
[project/ustream-ssl.git] / ustream-openssl.c
index dec2b9f7816d50e944b2dbac346327bb2c27bee7..ad77e721534c7dafa12c6060c7c687392b2477cc 100644 (file)
@@ -210,8 +210,15 @@ __hidden void __ustream_ssl_context_free(struct ustream_ssl_ctx *ctx)
 
 void __ustream_ssl_session_free(void *ssl)
 {
+       BIO *bio = SSL_get_wbio(ssl);
+       struct bio_ctx *ctx = BIO_get_data(bio);
+
        SSL_shutdown(ssl);
        SSL_free(ssl);
+       if (ctx) {
+               BIO_meth_free(ctx->meth);
+               free(ctx);
+       }
 }
 
 static void ustream_ssl_error(struct ustream_ssl *us, int ret)