X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Frequest.c;h=c2d6dd445da85bebc267cb70bf4580d798880261;hb=34ccd14f3e8c6a02ceae11c7b0d475e17d011984;hp=3998168ff187598605c6509849dcce4b50ce3151;hpb=ba4dd5b733448d85f815f6d45a6205c16adab7e8;p=openldap diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 3998168ff1..c2d6dd445d 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2014 The OpenLDAP Foundation. + * Copyright 1998-2015 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -128,7 +128,10 @@ ldap_send_initial_request( if ( ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, &sd ) == -1 ) { /* not connected yet */ rc = ldap_open_defconn( ld ); - + if ( rc == 0 ) { + ber_sockbuf_ctrl( ld->ld_defconn->lconn_sb, + LBER_SB_OPT_GET_FD, &sd ); + } } if ( ld->ld_defconn && ld->ld_defconn->lconn_status == LDAP_CONNST_CONNECTING ) rc = ldap_int_check_async_open( ld, sd ); @@ -485,6 +488,10 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb, if ( rc != -1 ) { srv = *srvp; + /* If we fully connected, async is moot */ + if ( rc == 0 ) + async = 0; + if ( ld->ld_urllist_proc && ( !async || rc != -2 ) ) { ld->ld_urllist_proc( ld, srvlist, srvp, ld->ld_urllist_params ); } @@ -503,6 +510,13 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb, } lc->lconn_server = ldap_url_dup( srv ); + if ( !lc->lconn_server ) { + if ( !use_ldsb ) + ber_sockbuf_free( lc->lconn_sb ); + LDAP_FREE( (char *)lc ); + ld->ld_errno = LDAP_NO_MEMORY; + return( NULL ); + } } lc->lconn_status = async ? LDAP_CONNST_CONNECTING : LDAP_CONNST_CONNECTED; @@ -1434,6 +1448,7 @@ ldap_chase_referrals( LDAP *ld, id, sref, srv, &rinfo.ri_request ); if ( ber == NULL ) { + ldap_free_urllist( srv ); return -1 ; }