From: Hallvard Furuseth Date: Mon, 1 Aug 2005 03:51:53 +0000 (+0000) Subject: Plug memory leaks - free() controls in LDAP* X-Git-Tag: OPENLDAP_AC_BP~123 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f9e505727e8f554c0d6e502c8983d8d19ab77575;p=openldap Plug memory leaks - free() controls in LDAP* --- diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index 6f678680cf..e8106c5e7d 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -388,7 +388,8 @@ ldap_set_option( LDAPControl *const *controls = (LDAPControl *const *) invalue; - ldap_controls_free( lo->ldo_sctrls ); + if( lo->ldo_sctrls ) + ldap_controls_free( lo->ldo_sctrls ); if( controls == NULL || *controls == NULL ) { lo->ldo_sctrls = NULL; @@ -407,7 +408,8 @@ ldap_set_option( LDAPControl *const *controls = (LDAPControl *const *) invalue; - ldap_controls_free( lo->ldo_cctrls ); + if( lo->ldo_cctrls ) + ldap_controls_free( lo->ldo_cctrls ); if( controls == NULL || *controls == NULL ) { lo->ldo_cctrls = NULL; diff --git a/libraries/libldap/unbind.c b/libraries/libldap/unbind.c index 0158edf5b4..c58d7a2a0a 100644 --- a/libraries/libldap/unbind.c +++ b/libraries/libldap/unbind.c @@ -172,6 +172,16 @@ ldap_ld_free( } #endif + if ( ld->ld_options.ldo_sctrls != NULL ) { + ldap_controls_free( ld->ld_options.ldo_sctrls ); + ld->ld_options.ldo_sctrls = NULL; + } + + if ( ld->ld_options.ldo_cctrls != NULL ) { + ldap_controls_free( ld->ld_options.ldo_cctrls ); + ld->ld_options.ldo_cctrls = NULL; + } + ber_sockbuf_free( ld->ld_sb ); #ifdef LDAP_R_COMPILE