From: Pierangelo Masarati Date: Mon, 2 Jan 2006 13:27:29 +0000 (+0000) Subject: fix leaks in ldap_parse_passwd() X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~486 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0e6f61aa03d7e1e83b713731b59f4a6f215d6cb9;p=openldap fix leaks in ldap_parse_passwd() --- diff --git a/libraries/libldap/passwd.c b/libraries/libldap/passwd.c index 49fe8bb24e..f65831ef12 100644 --- a/libraries/libldap/passwd.c +++ b/libraries/libldap/passwd.c @@ -36,8 +36,7 @@ int ldap_parse_passwd( struct berval *newpasswd ) { int rc; - char *retoid = NULL; - struct berval *retdata; + struct berval *retdata = NULL; assert( ld != NULL ); assert( LDAP_VALID( ld ) ); @@ -47,31 +46,32 @@ int ldap_parse_passwd( newpasswd->bv_val = NULL; newpasswd->bv_len = 0; - rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 0 ); - - if( rc != LDAP_SUCCESS ) { + rc = ldap_parse_extended_result( ld, res, NULL, &retdata, 0 ); + if ( rc != LDAP_SUCCESS ) { return rc; } - if( retdata != NULL ) { + if ( retdata != NULL ) { ber_tag_t tag; BerElement *ber = ber_init( retdata ); - if( ber == NULL ) { - ld->ld_errno = LDAP_NO_MEMORY; - return ld->ld_errno; + if ( ber == NULL ) { + rc = ld->ld_errno = LDAP_NO_MEMORY; + goto done; } /* we should check the tag */ tag = ber_scanf( ber, "{o}", newpasswd ); ber_free( ber, 1 ); - if( tag == LBER_ERROR ) { + if ( tag == LBER_ERROR ) { rc = ld->ld_errno = LDAP_DECODING_ERROR; } } - ber_memfree( retoid ); +done:; + ber_bvfree( retdata ); + return rc; }