diff --git a/vio/vio.cc b/vio/vio.cc index f9dc5ae45f6..e7410425ef0 100644 --- a/vio/vio.cc +++ b/vio/vio.cc @@ -535,6 +535,14 @@ int vio_timeout(Vio *vio, uint which, timeout_t timeout) { void internal_vio_delete(Vio *vio) { if (!vio) return; /* It must be safe to delete null pointers. */ if (vio->inactive == false) vio->vioshutdown(vio); + +#ifdef HAVE_OPENSSL + if (vio->ssl_arg) { + SSL_free((SSL *)vio->ssl_arg); + vio->ssl_arg = 0; + } +#endif + vio->~Vio(); my_free(vio); } diff --git a/vio/viossl.cc b/vio/viossl.cc index 34e7946ebc1..789dd6d108e 100644 --- a/vio/viossl.cc +++ b/vio/viossl.cc @@ -403,11 +403,6 @@ void vio_ssl_delete(Vio *vio) { if (vio->inactive == false) vio_ssl_shutdown(vio); /* Still open, close connection first */ - if (vio->ssl_arg) { - SSL_free((SSL *)vio->ssl_arg); - vio->ssl_arg = 0; - } - #ifndef HAVE_WOLFSSL #if OPENSSL_VERSION_NUMBER < 0x10100000L ERR_remove_thread_state(0);