From: Pierangelo Masarati Date: Fri, 14 Sep 2007 23:25:15 +0000 (+0000) Subject: add more sanity checks (ITS#5136) X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~640 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9f36fafe55d5f3cecc6d826fd4c038ca6d415857;p=openldap add more sanity checks (ITS#5136) --- diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 4dfca8a662..ac6ddd3c53 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -718,7 +718,21 @@ ordered_value_add( } new = ch_malloc( (anum+vnum+1) * sizeof(struct berval)); - if ( ( a->a_nvals && a->a_nvals != a->a_vals ) || ( nvals != NULL && nvals != vals ) ) { + + /* sanity check: if normalized modifications come in, either + * no values are present or normalized existing values differ + * from non-normalized; if no normalized modifications come in, + * either no values are present or normalized existing values + * don't differ from non-normalized */ + if ( nvals != NULL ) { + assert( nvals != vals ); + assert( a->a_nvals == NULL || a->a_nvals != a->a_vals ); + + } else { + assert( a->a_nvals == NULL || a->a_nvals == a->a_vals ); + } + + if ( ( a->a_nvals && a->a_nvals != a->a_vals ) || nvals != NULL ) { nnew = ch_malloc( (anum+vnum+1) * sizeof(struct berval)); /* Shouldn't happen... */ if ( !nvals ) nvals = vals;