]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/attr.c
fix previous commit
[openldap] / servers / slapd / attr.c
index 0de26e84e5212a5c82d2faeec9b5b09d0594ae80..63973e03cfa53ec2271214579cb3558f4eec0f52 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 void
 attr_free( Attribute *a )
 {
-       if ( a->a_nvals && a->a_nvals != a->a_vals )
+       if ( a->a_nvals && a->a_nvals != a->a_vals ) {
                ber_bvarray_free( a->a_nvals );
-       ber_bvarray_free( a->a_vals );
+       }
+       /* a_vals may be equal to slap_dummy_bv, a static empty berval;
+        * this is used as a placeholder for attributes that do not carry
+        * values, e.g. when proxying search entries with the "attrsonly"
+        * bit set. */
+       if ( a->a_vals != &slap_dummy_bv ) {
+               ber_bvarray_free( a->a_vals );
+       }
        free( a );
 }
 
@@ -176,7 +183,7 @@ attr_merge(
        Attribute       **a;
 
        for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
-               if ( ad_cmp( (*a)->a_desc, desc ) == 0 ) {
+               if (  (*a)->a_desc == desc ) {
                        break;
                }
        }
@@ -191,6 +198,13 @@ attr_merge(
 #ifdef LDAP_COMP_MATCH
                (*a)->a_comp_data = NULL;
 #endif
+       } else {
+               /*
+                * FIXME: if the attribute already exists, the presence
+                * of nvals and the value of (*a)->a_nvals must be consistent
+                */
+               assert( ( nvals == NULL && (*a)->a_nvals == (*a)->a_vals )
+                               || ( nvals != NULL && (*a)->a_nvals != (*a)->a_vals ) );
        }
 
        rc = value_add( &(*a)->a_vals, vals );
@@ -260,7 +274,7 @@ attr_merge_one(
        Attribute       **a;
 
        for ( a = &e->e_attrs; *a != NULL; a = &(*a)->a_next ) {
-               if ( ad_cmp( (*a)->a_desc, desc ) == 0 ) {
+               if ( (*a)->a_desc == desc ) {
                        break;
                }
        }
@@ -352,7 +366,7 @@ attr_find(
        AttributeDescription *desc )
 {
        for ( ; a != NULL; a = a->a_next ) {
-               if ( ad_cmp( a->a_desc, desc ) == 0 ) {
+               if ( a->a_desc == desc ) {
                        return( a );
                }
        }
@@ -375,7 +389,7 @@ attr_delete(
        Attribute       **a;
 
        for ( a = attrs; *a != NULL; a = &(*a)->a_next ) {
-               if ( ad_cmp( (*a)->a_desc, desc ) == 0 ) {
+               if ( (*a)->a_desc == desc ) {
                        Attribute       *save = *a;
                        *a = (*a)->a_next;
                        attr_free( save );