]> git.sur5r.net Git - openldap/commitdiff
handle attr delete appropriately (pass test004)
authorPierangelo Masarati <ando@openldap.org>
Tue, 4 Feb 2003 22:33:51 +0000 (22:33 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 4 Feb 2003 22:33:51 +0000 (22:33 +0000)
servers/slapd/slapi/slapi_utils.c

index fc38e6e587d0f79f3b20f315bccf8c0ea0a8c183..a89cf6db8915023c46408f10c9d16541d73da44a 100644 (file)
@@ -3127,21 +3127,25 @@ Modifications *slapi_x_ldapmods2modifications (LDAPMod **mods)
                                ;
                }
 
-               mod->sml_bvalues = (BerVarray) ch_malloc( (i + 1) * sizeof(struct berval) );
-
-               /* NB: This implicitly trusts a plugin to return valid modifications. */
-               if ( (*modp)->mod_op & LDAP_MOD_BVALUES ) {
-                       for( i = 0, bvp = (*modp)->mod_bvalues; bvp != NULL && *bvp != NULL; bvp++, i++ ) {
-                               mod->sml_bvalues[i].bv_val = (*bvp)->bv_val;
-                               mod->sml_bvalues[i].bv_len = (*bvp)->bv_len;
-                       }
+               if ( i == 0 ) {
+                        mod->sml_bvalues = NULL;
                } else {
-                       for( i = 0, p = (*modp)->mod_values; p != NULL && *p != NULL; p++, i++ ) {
-                               mod->sml_bvalues[i].bv_val = *p;
-                               mod->sml_bvalues[i].bv_len = strlen( *p );
+                       mod->sml_bvalues = (BerVarray) ch_malloc( (i + 1) * sizeof(struct berval) );
+
+                       /* NB: This implicitly trusts a plugin to return valid modifications. */
+                       if ( (*modp)->mod_op & LDAP_MOD_BVALUES ) {
+                               for( i = 0, bvp = (*modp)->mod_bvalues; bvp != NULL && *bvp != NULL; bvp++, i++ ) {
+                                       mod->sml_bvalues[i].bv_val = (*bvp)->bv_val;
+                                       mod->sml_bvalues[i].bv_len = (*bvp)->bv_len;
+                               }
+                       } else {
+                               for( i = 0, p = (*modp)->mod_values; p != NULL && *p != NULL; p++, i++ ) {
+                                       mod->sml_bvalues[i].bv_val = *p;
+                                       mod->sml_bvalues[i].bv_len = strlen( *p );
+                               }
                        }
+                       mod->sml_bvalues[i].bv_val = NULL;
                }
-               mod->sml_bvalues[i].bv_val = NULL;
 
                *modtail = mod;
                modtail = &mod->sml_next;