]> git.sur5r.net Git - openldap/commitdiff
Fix TLS CTX ref counting
authorHoward Chu <hyc@openldap.org>
Sun, 2 Jul 2006 22:38:01 +0000 (22:38 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 2 Jul 2006 22:38:01 +0000 (22:38 +0000)
libraries/libldap/tls.c
servers/slapd/main.c

index 3d8333f64ab0c62534d0b71f3715436a8ff2177f..fc2e31d55a7b57506916069d547d1dad91eb0614 100644 (file)
@@ -1366,6 +1366,7 @@ ldap_pvt_tls_set_option( LDAP *ld, int option, void *arg )
                if ( lo->ldo_tls_ctx )
                        SSL_CTX_free( lo->ldo_tls_ctx );
                lo->ldo_tls_ctx = arg;
+               CRYPTO_add( &((SSL_CTX *)arg)->references, 1, CRYPTO_LOCK_SSL_CTX );
                return 0;
        case LDAP_OPT_X_TLS_CONNECT_CB:
                lo->ldo_tls_connect_cb = (LDAP_TLS_CONNECT_CB *)arg;
index 5642c1b86c69e8fde77886ac1c205d5961e628bd..a62e633e388b0277b918790844aac6d26feaadd1 100644 (file)
@@ -959,11 +959,8 @@ stop:
        lutil_passwd_destroy();
 
 #ifdef HAVE_TLS
-       /* Setting it to itself decreases refcount, allowing it to be freed
-        * when the LD is freed.
-        */
        if ( slap_tls_ld ) {
-               ldap_pvt_tls_set_option( slap_tls_ld, LDAP_OPT_X_TLS_CTX, slap_tls_ctx );
+               SSL_CTX_free( slap_tls_ctx );
                ldap_unbind( slap_tls_ld );
        }
        ldap_pvt_tls_destroy();