diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index bea4dcbcd7..bb45b385c0 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -139,13 +139,18 @@ ldap_back_modify( ml->sml_bvalues, conn ); } #endif /* ENABLE_REWRITE */ - - for (j = 0; ml->sml_bvalues[j].bv_val; j++); - mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) * - sizeof(struct berval *)); - for (j = 0; ml->sml_bvalues[j].bv_val; j++) - mods[i].mod_bvalues[j] = &ml->sml_bvalues[j]; - mods[i].mod_bvalues[j] = NULL; + + if ( ml->sml_bvalues != NULL ) { + for (j = 0; ml->sml_bvalues[j].bv_val; j++); + mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) * + sizeof(struct berval *)); + for (j = 0; ml->sml_bvalues[j].bv_val; j++) + mods[i].mod_bvalues[j] = &ml->sml_bvalues[j]; + mods[i].mod_bvalues[j] = NULL; + } else { + mods[i].mod_bvalues = NULL; + } + i++; } modv[i] = 0; diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index b6890382c8..7b3208bc53 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -179,12 +179,18 @@ meta_back_modify( ml->sml_bvalues, conn ); } - for (j = 0; ml->sml_bvalues[ j ].bv_val; j++); - mods[ i ].mod_bvalues = (struct berval **)ch_malloc((j+1) * - sizeof(struct berval *)); - for (j = 0; ml->sml_bvalues[ j ].bv_val; j++) - mods[ i ].mod_bvalues[ j ] = &ml->sml_bvalues[j]; - mods[ i ].mod_bvalues[ j ] = NULL; + if ( ml->sml_bvalues != NULL ){ + for (j = 0; ml->sml_bvalues[ j ].bv_val; j++); + mods[ i ].mod_bvalues = (struct berval **)ch_malloc((j+1) * + sizeof(struct berval *)); + for (j = 0; ml->sml_bvalues[ j ].bv_val; j++) + mods[ i ].mod_bvalues[ j ] = &ml->sml_bvalues[j]; + mods[ i ].mod_bvalues[ j ] = NULL; + + } else { + mods[ i ].mod_bvalues = NULL; + } + i++; } modv[ i ] = 0;