ctx = ld->ld_defconn->lconn_sasl_authctx;
rc = ldap_parse_sasl_bind_result( ld, result, &scred, 0 );
- if ( rc != LDAP_SUCCESS )
+ if ( rc != LDAP_SUCCESS ) {
+ if ( scred )
+ ber_bvfree( scred );
goto done;
+ }
rc = ldap_result2error( ld, result, 0 );
if ( rc != LDAP_SUCCESS && rc != LDAP_SASL_BIND_IN_PROGRESS ) {
}
mech = *rmech;
- if ( rc == LDAP_SUCCESS && mech == NULL )
+ if ( rc == LDAP_SUCCESS && mech == NULL ) {
+ if ( scred )
+ ber_bvfree( scred );
goto success;
+ }
do {
if( ! scred ) {