diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index 2acfbade17..62e305640b 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -515,7 +515,8 @@ int ldap_int_sasl_close( LDAP *ld, LDAPConn *lc ) if( ctx != NULL ) { sasl_dispose( &ctx ); - if ( lc->lconn_sasl_sockctx && ctx != lc->lconn_sasl_sockctx ) { + if ( lc->lconn_sasl_sockctx && + lc->lconn_sasl_authctx != lc->lconn_sasl_sockctx ) { ctx = lc->lconn_sasl_sockctx; sasl_dispose( &ctx ); }