From f1bf9457e598d664c8531aaa35d196d66a5c7e37 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 4 Feb 2015 03:16:20 +0000 Subject: [PATCH] ITS#8050 fix ldap_get_option(LDAP_OPT_SESSION_REFCNT) --- libraries/libldap/options.c | 2 ++ libraries/libldap/unbind.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index 4d612a8c35..5762d6a193 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -371,7 +371,9 @@ ldap_get_option( /* bad param */ break; } + LDAP_MUTEX_LOCK( &ld->ld_ldcmutex ); * (int *) outvalue = ld->ld_ldcrefcnt; + LDAP_MUTEX_UNLOCK( &ld->ld_ldcmutex ); rc = LDAP_OPT_SUCCESS; break; diff --git a/libraries/libldap/unbind.c b/libraries/libldap/unbind.c index 385ad9e711..a49c040dc2 100644 --- a/libraries/libldap/unbind.c +++ b/libraries/libldap/unbind.c @@ -97,13 +97,14 @@ ldap_ld_free( if ( ld->ld_referrals != NULL) { LDAP_VFREE(ld->ld_referrals); ld->ld_referrals = NULL; - } + } LDAP_MUTEX_UNLOCK( &ld->ld_ldcmutex ); LDAP_FREE( (char *) ld ); return( err ); } /* This ld is the last thread. */ + LDAP_MUTEX_UNLOCK( &ld->ld_ldcmutex ); /* free LDAP structure and outstanding requests/responses */ LDAP_MUTEX_LOCK( &ld->ld_req_mutex ); @@ -123,7 +124,7 @@ ldap_ld_free( next = lm->lm_next; ldap_msgfree( lm ); } - + if ( ld->ld_abandoned != NULL ) { LDAP_FREE( ld->ld_abandoned ); ld->ld_abandoned = NULL; @@ -159,8 +160,8 @@ ldap_ld_free( if ( ld->ld_referrals != NULL) { LDAP_VFREE(ld->ld_referrals); ld->ld_referrals = NULL; - } - + } + if ( ld->ld_selectinfo != NULL ) { ldap_free_select_info( ld->ld_selectinfo ); ld->ld_selectinfo = NULL; @@ -227,7 +228,6 @@ ldap_ld_free( ldap_pvt_thread_mutex_destroy( &ld->ld_res_mutex ); ldap_pvt_thread_mutex_destroy( &ld->ld_abandon_mutex ); ldap_pvt_thread_mutex_destroy( &ld->ld_ldopts_mutex ); - ldap_pvt_thread_mutex_unlock( &ld->ld_ldcmutex ); ldap_pvt_thread_mutex_destroy( &ld->ld_ldcmutex ); #endif #ifndef NDEBUG @@ -235,7 +235,7 @@ ldap_ld_free( #endif LDAP_FREE( (char *) ld->ldc ); LDAP_FREE( (char *) ld ); - + return( err ); } -- 2.39.5