From cfc73a837b65d1f5240436af2b53507c0efd9dce Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 22 Apr 2005 21:34:49 +0000 Subject: [PATCH] Fix prev commit --- servers/slapd/bconfig.c | 64 ++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 060b0f151f..06f97a1006 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -3253,6 +3253,7 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs, case LDAP_MOD_REPLACE: { BerVarray vals = NULL, nvals; Attribute *a; + delrec *d; a = attr_find( e->e_attrs, ml->sml_desc ); @@ -3262,40 +3263,43 @@ config_modify_internal( CfEntryInfo *ce, Operation *op, SlapReply *rs, ml->sml_values = NULL; ml->sml_nvalues = NULL; } + + if ( ml->sml_values ) + d = dels; + /* If we didn't delete the whole attribute */ - if ( ml->sml_values ) { - delrec *d = dels; - if ( a ) { - struct berval *mvals; - int j; - - if ( ml->sml_nvalues ) - mvals = ml->sml_nvalues; - else - mvals = ml->sml_values; - - /* use the indexes we saved up above */ - for (i=0; i < d->nidx; i++) { - struct berval bv = *mvals++; - if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED && - bv.bv_val[0] == '{' ) { - ptr = strchr( bv.bv_val, '}' ) + 1; - bv.bv_len -= ptr - bv.bv_val; - bv.bv_val = ptr; - } - ca.line = bv.bv_val; - ca.valx = d->idx[i]; - rc = config_del_vals( ct, &ca ); - if ( rc != LDAP_SUCCESS ) break; - for (j=i+1; j < d->nidx; j++) - if ( d->idx[j] >d->idx[i] ) - d->idx[j]--; + if ( ml->sml_values && a ) { + struct berval *mvals; + int j; + + if ( ml->sml_nvalues ) + mvals = ml->sml_nvalues; + else + mvals = ml->sml_values; + + /* use the indexes we saved up above */ + for (i=0; i < d->nidx; i++) { + struct berval bv = *mvals++; + if ( a->a_desc->ad_type->sat_flags & SLAP_AT_ORDERED && + bv.bv_val[0] == '{' ) { + ptr = strchr( bv.bv_val, '}' ) + 1; + bv.bv_len -= ptr - bv.bv_val; + bv.bv_val = ptr; } - } else { - ca.valx = -1; - ca.line = NULL; + ca.line = bv.bv_val; + ca.valx = d->idx[i]; rc = config_del_vals( ct, &ca ); + if ( rc != LDAP_SUCCESS ) break; + for (j=i+1; j < d->nidx; j++) + if ( d->idx[j] >d->idx[i] ) + d->idx[j]--; } + } else { + ca.valx = -1; + ca.line = NULL; + rc = config_del_vals( ct, &ca ); + } + if ( ml->sml_values ) { ch_free( dels ); dels = d->next; } -- 2.39.5