mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
Move delete of last value check out of inner loop.
This commit is contained in:
parent
f48f00f995
commit
20248e7430
@ -379,26 +379,17 @@ delete_values(
|
|||||||
if( rc == LDAP_SUCCESS && match != 0 ) {
|
if( rc == LDAP_SUCCESS && match != 0 ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* found a matching value */
|
||||||
found = 1;
|
found = 1;
|
||||||
|
|
||||||
/* found a matching value - delete it */
|
/* delete it */
|
||||||
ber_bvfree( a->a_vals[j] );
|
ber_bvfree( a->a_vals[j] );
|
||||||
for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
|
for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
|
||||||
a->a_vals[k - 1] = a->a_vals[k];
|
a->a_vals[k - 1] = a->a_vals[k];
|
||||||
}
|
}
|
||||||
a->a_vals[k - 1] = NULL;
|
a->a_vals[k - 1] = NULL;
|
||||||
|
|
||||||
/* delete the entire attribute, if no values remain */
|
|
||||||
if ( a->a_vals[0] == NULL) {
|
|
||||||
Debug( LDAP_DEBUG_ARGS,
|
|
||||||
"removing entire attribute %s\n",
|
|
||||||
desc, 0, 0 );
|
|
||||||
if ( attr_delete( &e->e_attrs, mod->sm_desc ) ) {
|
|
||||||
ber_bvfree( asserted );
|
|
||||||
return LDAP_NO_SUCH_ATTRIBUTE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,6 +404,16 @@ delete_values(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if no values remain, delete the entire attribute */
|
||||||
|
if ( a->a_vals[0] == NULL ) {
|
||||||
|
Debug( LDAP_DEBUG_ARGS,
|
||||||
|
"removing entire attribute %s\n",
|
||||||
|
desc, 0, 0 );
|
||||||
|
if ( attr_delete( &e->e_attrs, mod->sm_desc ) ) {
|
||||||
|
return LDAP_NO_SUCH_ATTRIBUTE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return LDAP_SUCCESS;
|
return LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user