X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fgetvalues.c;h=1ac26f447a59887da8a4097c35f07d4a7b947308;hb=c8e37af0ca8302c276e8c6af84eca4f926171261;hp=865688e535635a37966e574e856a3a0fe58cf21a;hpb=22d98c85c3ece96dd2e3d9b76195973d0639cd49;p=openldap diff --git a/libraries/libldap/getvalues.c b/libraries/libldap/getvalues.c index 865688e535..1ac26f447a 100644 --- a/libraries/libldap/getvalues.c +++ b/libraries/libldap/getvalues.c @@ -12,7 +12,8 @@ #include "portable.h" #include -#include + +#include #include #include @@ -29,12 +30,17 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) int found = 0; char **vals; + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); + assert( target != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 ); ber = *entry->lm_ber; /* skip sequence, dn, sequence of, and snag the first attr */ - if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) { + if ( ber_scanf( &ber, "{x{{a" /*}}}*/, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } @@ -44,10 +50,10 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) /* break out on success, return out on error */ while ( ! found ) { - free(attr); + LDAP_FREE(attr); attr = NULL; - if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) { + if ( ber_scanf( &ber, /*{*/ "x}{a" /*}*/, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } @@ -57,7 +63,7 @@ ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) } - free(attr); + LDAP_FREE(attr); attr = NULL; /* @@ -81,12 +87,17 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) int found = 0; struct berval **vals; + assert( ld != NULL ); + assert( LDAP_VALID( ld ) ); + assert( entry != NULL ); + assert( target != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 ); ber = *entry->lm_ber; /* skip sequence, dn, sequence of, and snag the first attr */ - if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) { + if ( ber_scanf( &ber, "{x{{a" /* }}} */, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } @@ -96,10 +107,10 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) /* break out on success, return out on error */ while ( ! found ) { - free( attr ); + LDAP_FREE( attr ); attr = NULL; - if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) { + if ( ber_scanf( &ber, /*{*/ "x}{a" /*}*/, &attr ) == LBER_ERROR ) { ld->ld_errno = LDAP_DECODING_ERROR; return( NULL ); } @@ -108,7 +119,7 @@ ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target ) break; } - free( attr ); + LDAP_FREE( attr ); attr = NULL; /* @@ -147,25 +158,11 @@ ldap_count_values_len( struct berval **vals ) void ldap_value_free( char **vals ) { - int i; - - if ( vals == NULL ) - return; - for ( i = 0; vals[i] != NULL; i++ ) - free( vals[i] ); - free( (char *) vals ); + LDAP_VFREE( vals ); } void ldap_value_free_len( struct berval **vals ) { - int i; - - if ( vals == NULL ) - return; - for ( i = 0; vals[i] != NULL; i++ ) { - free( vals[i]->bv_val ); - free( vals[i] ); - } - free( (char *) vals ); + ber_bvecfree( vals ); }