diff --git a/libraries/libldap/passwd.c b/libraries/libldap/passwd.c index d2d32b58a5..a186abe040 100644 --- a/libraries/libldap/passwd.c +++ b/libraries/libldap/passwd.c @@ -146,6 +146,10 @@ ldap_passwd_s( } rc = ldap_parse_passwd( ld, res, newpasswd ); - ldap_msgfree( res ); - return rc; + if( rc != LDAP_SUCCESS ) { + ldap_msgfree( res ); + return rc; + } + + return( ldap_result2error( ld, res, 1 ) ); } diff --git a/libraries/libldap/whoami.c b/libraries/libldap/whoami.c index 3ad13869c9..23fe395301 100644 --- a/libraries/libldap/whoami.c +++ b/libraries/libldap/whoami.c @@ -80,6 +80,10 @@ ldap_whoami_s( } rc = ldap_parse_whoami( ld, res, authzid ); - ldap_msgfree( res ); - return rc; + if( rc != LDAP_SUCCESS ) { + ldap_msgfree( res ); + return rc; + } + + return( ldap_result2error( ld, res, 1 ) ); }