mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
rework of slap_mods2entry dup
This commit is contained in:
parent
c7d4f2841e
commit
dda85fafe9
@ -422,24 +422,32 @@ slap_mods2entry(
|
|||||||
|
|
||||||
/* should check for duplicates */
|
/* should check for duplicates */
|
||||||
|
|
||||||
AC_MEMCPY( &attr->a_vals[i], mods->sml_values,
|
if ( dup ) {
|
||||||
sizeof( struct berval ) * j );
|
for ( j = 0; mods->sml_values[j].bv_val; j++ ) {
|
||||||
|
ber_dupbv( &attr->a_vals[i+j], &mods->sml_values[j] );
|
||||||
/* trim the mods array */
|
}
|
||||||
ch_free( mods->sml_values );
|
BER_BVZERO( &attr->a_vals[i+j] );
|
||||||
mods->sml_values = NULL;
|
} else {
|
||||||
|
AC_MEMCPY( &attr->a_vals[i], mods->sml_values,
|
||||||
|
sizeof( struct berval ) * j );
|
||||||
|
ch_free( mods->sml_values );
|
||||||
|
mods->sml_values = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if( mods->sml_nvalues ) {
|
if( mods->sml_nvalues ) {
|
||||||
attr->a_nvals = ch_realloc( attr->a_nvals,
|
attr->a_nvals = ch_realloc( attr->a_nvals,
|
||||||
sizeof( struct berval ) * (i+j) );
|
sizeof( struct berval ) * (i+j) );
|
||||||
|
if ( dup ) {
|
||||||
AC_MEMCPY( &attr->a_nvals[i], mods->sml_nvalues,
|
for ( j = 0; mods->sml_nvalues[j].bv_val; j++ ) {
|
||||||
sizeof( struct berval ) * j );
|
ber_dupbv( &attr->a_nvals[i+j], &mods->sml_nvalues[j] );
|
||||||
|
}
|
||||||
/* trim the mods array */
|
BER_BVZERO( &attr->a_nvals[i+j] );
|
||||||
ch_free( mods->sml_nvalues );
|
} else {
|
||||||
mods->sml_nvalues = NULL;
|
AC_MEMCPY( &attr->a_nvals[i], mods->sml_nvalues,
|
||||||
|
sizeof( struct berval ) * j );
|
||||||
|
ch_free( mods->sml_nvalues );
|
||||||
|
mods->sml_nvalues = NULL;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
attr->a_nvals = attr->a_vals;
|
attr->a_nvals = attr->a_vals;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user