diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/openssl/ossl_ssl.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index a95ab3d1d0..f314a7ac25 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -1566,18 +1566,22 @@ static VALUE ossl_ssl_close(VALUE self) { SSL *ssl; + VALUE io; - ossl_ssl_data_get_struct(self, ssl); + /* ossl_ssl_data_get_struct() is not usable here because it may return + * from this function; */ - if (ssl) { - VALUE io = ossl_ssl_get_io(self); - if (!RTEST(rb_funcall(io, rb_intern("closed?"), 0))) { - ossl_ssl_shutdown(ssl); - SSL_free(ssl); - DATA_PTR(self) = NULL; - if (RTEST(ossl_ssl_get_sync_close(self))) - rb_funcall(io, rb_intern("close"), 0); - } + Data_Get_Struct(self, SSL, ssl); + + io = ossl_ssl_get_io(self); + if (!RTEST(rb_funcall(io, rb_intern("closed?"), 0))) { + if (ssl) { + ossl_ssl_shutdown(ssl); + SSL_free(ssl); + } + DATA_PTR(self) = NULL; + if (RTEST(ossl_ssl_get_sync_close(self))) + rb_funcall(io, rb_intern("close"), 0); } return Qnil; |