PR: 2073
authorDr. Stephen Henson <steve@openssl.org>
Fri, 16 Oct 2009 13:42:15 +0000 (13:42 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 16 Oct 2009 13:42:15 +0000 (13:42 +0000)
Submitted by: Tomas Mraz <tmraz@redhat.com>
Approved by: steve@openssl.org

Don't access freed SSL_CTX in SSL_free().

ssl/ssl_lib.c

index c3a9a6d70658e818a7a3e91f8a6a4e638b5f92eb..99e53fbdaff41870d1670d225c234215cf052b45 100644 (file)
@@ -508,7 +508,6 @@ void SSL_free(SSL *s)
        if (s->cert != NULL) ssl_cert_free(s->cert);
        /* Free up if allocated */
 
-       if (s->ctx) SSL_CTX_free(s->ctx);
 #ifndef OPENSSL_NO_TLSEXT
        if (s->tlsext_hostname)
                OPENSSL_free(s->tlsext_hostname);
@@ -526,6 +525,8 @@ void SSL_free(SSL *s)
 
        if (s->method != NULL) s->method->ssl_free(s);
 
+       if (s->ctx) SSL_CTX_free(s->ctx);
+
 #ifndef        OPENSSL_NO_KRB5
        if (s->kssl_ctx != NULL)
                kssl_ctx_free(s->kssl_ctx);