]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Avoid premature free
authorKurt Zeilenga <kurt@openldap.org>
Wed, 17 Jan 2001 05:27:21 +0000 (05:27 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 17 Jan 2001 05:27:21 +0000 (05:27 +0000)
libraries/libldap/open.c

index 87f2bc2e760f0f4ee6506ef777a7ca4b18effb40..a86b872e0c14fd6e7eb1ea27058bd2aeaa05943d 100644 (file)
@@ -329,9 +329,16 @@ ldap_int_open_connection(
        if (ld->ld_options.ldo_tls_mode == LDAP_OPT_X_TLS_HARD ||
                strcmp( srv->lud_scheme, "ldaps" ) == 0 )
        {
+               LDAPConn        *savedefconn = ld->ld_defconn;
+               ++conn->lconn_refcnt;   /* avoid premature free */
+               ld->ld_defconn = conn;
+
                rc = ldap_pvt_tls_start( ld, conn->lconn_sb,
                        ld->ld_options.ldo_tls_ctx );
 
+               ld->ld_defconn = savedefconn;
+               --conn->lconn_refcnt;
+
                if (rc != LDAP_SUCCESS) {
                        return -1;
                }