]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/open.c
Fix ldap_send_initial_request() to open connection if not already
[openldap] / libraries / libldap / open.c
index fd7f8e809c9d2936a979a24454aecd5d8025e365..5792b92e0a5a6a41efc5308b776ef08e36eaaa26 100644 (file)
@@ -48,13 +48,11 @@ ldap_open( char *host, int port )
                return( NULL );
        }
 
-       /* we'll assume we're talking version 2 for now */
-       ld->ld_version = LDAP_VERSION2;
-
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
        if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) ==
            NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
-           ldap_strdup( ld->ld_defhost )) == NULL )) {
+           strdup( ld->ld_defhost )) == NULL )) {
+               if(srv != NULL) free( (char*) srv );
                ldap_ld_free( ld, 0 );
                return( NULL );
        }
@@ -153,9 +151,9 @@ ldap_init( char *defhost, int defport )
        ld->ld_options.ldo_defhost = NULL;
 
        if ( defhost != NULL ) {
-               ld->ld_options.ldo_defhost = ldap_strdup( defhost );
+               ld->ld_options.ldo_defhost = strdup( defhost );
        } else {
-               ld->ld_options.ldo_defhost = ldap_strdup(
+               ld->ld_options.ldo_defhost = strdup(
                        openldap_ldap_global_options.ldo_defhost);
        }
 
@@ -166,7 +164,7 @@ ldap_init( char *defhost, int defport )
        }
 
        if ( openldap_ldap_global_options.ldo_defbase != NULL ) {
-               ld->ld_options.ldo_defbase = ldap_strdup(
+               ld->ld_options.ldo_defbase = strdup(
                        openldap_ldap_global_options.ldo_defbase);
        }
 
@@ -195,6 +193,10 @@ ldap_init( char *defhost, int defport )
 #endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
 #endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
 
+       /* we'll assume we're talking version 2 for now */
+       ld->ld_version = LDAP_VERSION2;
+
+       ld->ld_sb.sb_sd = -1;
        return( ld );
 }